+3

Triển khai API Gateway trong .NET Core với Ocelot - Quản lý API Gateway với Swagger

Trước đây, để quản lý các API, ta có công cụ là Swagger, tuy nhiên đối với API Gateway như Ocelot thì sao? Trong bài viết này, mình sẽ hướng dẫn cách setup Swagger để quản lý tài liệu API Gateway với SwaggerForOcelot - tổng hợp các service swagger

a. Install package MMLib.SwaggerForOcelot

b. Config tại program

image.png

c. Cấu hình lại từng route bằng cách thêm swagger key và {everything} ở path

image.png

d. Config swagger endpoints

image.png

e. Kết quả

image.png

Tài liệu tham khảo

[1] https://ocelot.readthedocs.io/en/latest/introduction/bigpicture.html

[2] https://www.c-sharpcorner.com/article/building-api-gateway-using-ocelot-in-asp-net-core/


All rights reserved

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí