The library provides an interface your Gateway API can implement to hook into the Gateway's middleware.
In your Gateway API project,
Task Invoke(HttpContext context, string apiKey, string routeKey);
In your Gateway API project,
- Create a service like below
public class GatewayMiddlewareService : IGatewayMiddleware
{
public async Task Invoke(HttpContext context, string apiKey, string routeKey)
{
//do your work here
await Task.CompletedTask;
}
}
- Wire it up for dependency injection in Startup.cs
services.AddTransient<IGatewayMiddleware, GatewayMiddlewareService>();
.
.
services.AddApiGateway();