Table of Contents
This repository contains some samples that show ocelot features in different projects from basic to advance config.
An API gateway is an API management tool that sits between a client and a collection of backend services.
An API gateway acts as a reverse proxy to accept all application programming interface (API) calls, aggregate the various services required to fulfill them, and return the appropriate result.
Benefits of API gateways
- Security
- API authentication
- Input validation
- Filtering
- Faster response times
- load balancing
- Rate limiting
- Expose only one endpoint
- Billing for microservices
- caching
- Monitoring and tracking
- Extending legacy apps
Ocelot is a .NET API Gateway. This project is aimed at people using .NET running a micro services/service-oriented architecture that needs a unified point of entry into their system. However, it will work with anything that speaks HTTP and run on any platform that ASP.NET Core supports.
For a quick list of Ocelot's capabilities for more information see the documentation.
- Routing
- Request Aggregation
- Service Discovery with Consul & Eureka
- Service Fabric
- Kubernetes
- WebSockets
- Authentication
- Authorization
- Rate Limiting
- Caching
- Retry policies / QoS
- Load Balancing
- Logging / Tracing / Correlation
- Headers / Method / Query String / Claims Transformation
- Custom Middleware / Delegating Handlers
- Configuration / Administration REST API
- Platform / Cloud Agnostic
Ocelot is designed to work with ASP.NET and it targets net6.0
.
Install Ocelot and it's dependencies using NuGet.
Install-Package Ocelot
Or via the .NET Core CLI:
dotnet add package ocelot
All versions can be found here
The simplest sample that introduces how to use Ocelot here.
Link here : Basic
Same as the Basic template but routes requests to multi services.
Link here : Mulit Services
In this project, receive request and collect response from two different services.
Link here : Request Aggregation
In this project, use Serilog for log all request in file.
Link here : Logging
In this project, handle authentication and authorization with JWT Token.
Link here : Authentication And Authorization
In this project, handle client request limitation in custom periodic time per endpoint.
Link here : RateLimit
In this project, use CacheManager for caching output response.
Link here : Caching
In this project, Balance request to multi same service.
Link here : Load Balance
In this project, Enable Swagger for APIs.
Link here : Swagger
In this project, Enable circuit breaker.
Link here : QoS