All Projects → VeritasSoftware → AspNetCore.ApiGateway

VeritasSoftware / AspNetCore.ApiGateway

Licence: MIT license
Asp Net Core Api Gateway Framework

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to AspNetCore.ApiGateway

Dgate
an API Gateway based on Vert.x
Stars: ✭ 222 (+382.61%)
Mutual labels:  api-gateway
zeppelin-gateway
Object Gateway Provide Applications with a RESTful Gateway to zeppelin
Stars: ✭ 24 (-47.83%)
Mutual labels:  api-gateway
rocket-lamb
A crate to allow running a Rocket webserver as an AWS Lambda Function with API Gateway or an Application Load Balancer
Stars: ✭ 73 (+58.7%)
Mutual labels:  api-gateway
Aspnetcore.proxy
ASP.NET Core Proxies made easy.
Stars: ✭ 234 (+408.7%)
Mutual labels:  api-gateway
yappa
Serverless deploy of python web-apps @yandexcloud
Stars: ✭ 57 (+23.91%)
Mutual labels:  api-gateway
api-gateway
Node.js API gateway that works as single entry point for all clients in a MicroService architecture pattern.
Stars: ✭ 26 (-43.48%)
Mutual labels:  api-gateway
Apilogs
Easy logging and debugging for Amazon API Gateway and AWS Lambda Serverless APIs
Stars: ✭ 216 (+369.57%)
Mutual labels:  api-gateway
sls-photos-upload-service
Example web app and serverless API for uploading photos and saving to S3 and DynamoDB
Stars: ✭ 50 (+8.7%)
Mutual labels:  api-gateway
CloudFrontier
Monitor the internet attack surface of various public cloud environments. Currently supports AWS, GCP, Azure, DigitalOcean and Oracle Cloud.
Stars: ✭ 102 (+121.74%)
Mutual labels:  api-gateway
image-resizer-service
Serverless image resizing service for AWS
Stars: ✭ 95 (+106.52%)
Mutual labels:  api-gateway
Krakend Ce
KrakenD Community Edition. Make your binary of KrakenD API Gateway
Stars: ✭ 245 (+432.61%)
Mutual labels:  api-gateway
kong-plugin-url-rewrite
Kong API Gateway plugin for url-rewrite purposes
Stars: ✭ 43 (-6.52%)
Mutual labels:  api-gateway
realtime-transport-dashboards
Serverless APIs for AWS to build and display public transports real time data (Serverless application example)
Stars: ✭ 23 (-50%)
Mutual labels:  api-gateway
Apicast
3scale API Gateway
Stars: ✭ 225 (+389.13%)
Mutual labels:  api-gateway
GatewayService
GatewayService (Ocelot).
Stars: ✭ 19 (-58.7%)
Mutual labels:  api-gateway
Goku Api Gateway
A Powerful HTTP API Gateway in pure golang!Goku API Gateway (中文名:悟空 API 网关)是一个基于 Golang开发的微服务网关,能够实现高性能 HTTP API 转发、服务编排、多租户管理、API 访问权限控制等目的,拥有强大的自定义插件系统可以自行扩展,并且提供友好的图形化配置界面,能够快速帮助企业进行 API 服务治理、提高 API 服务的稳定性和安全性。
Stars: ✭ 2,773 (+5928.26%)
Mutual labels:  api-gateway
serverless-go
Serverless Golang Function to Discover Movies 🎥
Stars: ✭ 37 (-19.57%)
Mutual labels:  api-gateway
gobis
Gobis is a lightweight API Gateway written in go which can be used programmatically or as a standalone server.
Stars: ✭ 48 (+4.35%)
Mutual labels:  api-gateway
go2gql
graphql-go schema generator by proto files
Stars: ✭ 33 (-28.26%)
Mutual labels:  api-gateway
serverless-content-encoding
Serverless plugin to enable content encoding for response compression
Stars: ✭ 14 (-69.57%)
Mutual labels:  api-gateway

AspNetCore.ApiGateway

Asp Net Core Api Gateway package.

Build Status

Packages Version & Downloads
AspNetCore.ApiGateway NuGet Version and Downloads count
AspNetCore.ApiGateway.Client NuGet Version and Downloads count

The microservices architecture uses an Api Gateway as shown below.

Architecture

The package:

  • Makes creating an Api Gateway a breeze!!

Features

  • Swagger
  • Authorization
  • Filters
    • Action
    • Exception
    • Result
  • Load balancing
  • Response caching
  • Web sockets
  • Event sourcing
  • Request aggregation
  • Middleware service
  • Logging

Gateway as a Microservice Facade

Your Gateway API is a microservice which exposes endpoints that are a facade over your backend API endpoints.

  • GET
  • HEAD
  • POST
  • PUT
  • PATCH
  • DELETE

API Gateway Facade

Implementation

In the solution, there are 2 back end APIs : Weather API and Stock API.

For eg. To make a GET call to the backend API, you would set up an Api and a GET Route in your Gateway API's Api Orchestrator.

Then, the client app would make a GET call to the Gateway API which would make a GET call to the backend API using HttpClient.

In your Backend API project

Let us say you have a GET endpoint like this.

  • HTTP GET - /weatherforecast/forecast

In your Gateway API project

You add a Route for the backend GET call in the Api Orchrestrator.

Add a reference to the package and...

  • Create an Api Orchestration.

    You create an Api (weatherservice) and add a Route (forecast).

    public static class ApiOrchestration
    {
        public static void Create(IApiOrchestrator orchestrator, IApplicationBuilder app)
        {
            var serviceProvider = app.ApplicationServices;

            var weatherService = serviceProvider.GetService<IWeatherService>();

            var weatherApiClientConfig = weatherService.GetClientConfig();

            orchestrator.StartGatewayHub = true;
            orchestrator.GatewayHubUrl = "https://localhost:44360/GatewayHub";

            orchestrator.AddApi("weatherservice", "http://localhost:63969/")
                                //Get
                                .AddRoute("forecast", GatewayVerb.GET, new RouteInfo { Path = "weatherforecast/forecast", ResponseType = typeof(IEnumerable<WeatherForecast>) })
                                //Head
                                .AddRoute("forecasthead", GatewayVerb.HEAD, new RouteInfo { Path = "weatherforecast/forecast" })
                                //Get with params
                                .AddRoute("typewithparams", GatewayVerb.GET, new RouteInfo {  Path = "weatherforecast/types/{index}"})
                                //Get using custom HttpClient
                                .AddRoute("types", GatewayVerb.GET, new RouteInfo { Path = "weatherforecast/types", ResponseType = typeof(string[]), HttpClientConfig = weatherApiClientConfig })
                                //Get with param using custom HttpClient
                                .AddRoute("type", GatewayVerb.GET, new RouteInfo { Path = "weatherforecast/types/", ResponseType = typeof(WeatherTypeResponse), HttpClientConfig = weatherApiClientConfig })
                                //Get using custom implementation
                                .AddRoute("typescustom", GatewayVerb.GET, weatherService.GetTypes)
                                //Post
                                .AddRoute("add", GatewayVerb.POST, new RouteInfo { Path = "weatherforecast/types/add", RequestType = typeof(AddWeatherTypeRequest), ResponseType = typeof(string[])})
                                //Put
                                .AddRoute("update", GatewayVerb.PUT, new RouteInfo { Path = "weatherforecast/types/update", RequestType = typeof(UpdateWeatherTypeRequest), ResponseType = typeof(string[]) })
                                //Patch
                                .AddRoute("patch", GatewayVerb.PATCH, new RouteInfo { Path = "weatherforecast/forecast/patch", ResponseType = typeof(WeatherForecast) })
                                //Delete
                                .AddRoute("remove", GatewayVerb.DELETE, new RouteInfo { Path = "weatherforecast/types/remove/", ResponseType = typeof(string[]) })
                        .AddApi("stockservice", "http://localhost:63967/")
                                .AddRoute("stocks", GatewayVerb.GET, new RouteInfo { Path = "stock", ResponseType = typeof(IEnumerable<StockQuote>) })
                                .AddRoute("stock", GatewayVerb.GET, new RouteInfo { Path = "stock/", ResponseType = typeof(StockQuote) })                                
                        .AddHub("chatservice", ConnectionHelpers.BuildHubConnection, "2f85e3c6-66d2-48a3-8ff7-31a65073558b")
                                .AddRoute("room", new HubRouteInfo { InvokeMethod = "SendMessage", ReceiveMethod = "ReceiveMessage", ReceiveParameterTypes = new Type[] { typeof(string), typeof(string) } })
                        .AddEventSource("eventsourceservice", ConnectionHelpers.BuildEventSourceConnection, "281802b8-6f19-4b9d-820c-9ed29ee127f3")
                                .AddRoute("mystream", new EventSourceRouteInfo { ReceiveMethod = "ReceiveMyStreamEvent", Type = EventSourcingType.EventStore, OperationType = EventSourcingOperationType.PublishSubscribe, StreamName = "my-stream", GroupName = "my-group" });
        }
    }
  • Hook up in Startup.cs
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddTransient<IWeatherService, WeatherService>();

            //Api gateway
            services.AddApiGateway();

            services.AddControllers();

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo { Title = "My Api Gateway", Version = "v1" });
            });
        }

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseSwagger();

            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My Api Gateway");
            });

            //Api gateway
            app.UseApiGateway(orchestrator => ApiOrchestration.Create(orchestrator, app));

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                //GatewayHub endpoint
                endpoints.MapHub<GatewayHub>("/gatewayhub");
                endpoints.MapControllers();
            });
        }

The Gateway Swagger appears as shown below:

API Gateway Swagger

To call the forecast Route on the weather service Api,

you can enter the Api key and Route key into Swagger as below:

API Gateway Swagger

This will hit the weatherforecast/forecast endpoint on the backend Weather API.

You can check out how the Api Gateway supported Verbs are used below.

Verbs Usage

You can check out how the Api Gateway's endpoint Authorization support below.

Authorization

Customizations

  • You can customize the default HttpClient which the endpoints use to hit the backend api.
  • You can use your own HttpClient to hit the backend Api.
  • You can create your own implementation to hit the backend Api.

For Request aggregation, see this section.

Customizations

Load Balancing

Load Balancing

Response Caching

Response Caching

Web Sockets

Web Sockets

Event Sourcing

Event Sourcing

Filters

Middleware Service

Middleware Service

Viewing your Gateway's Api Orchestration

Your Gateway's Api Orchestration is published by GET /api/Gateway/orchestration endpoint.

Viewing Api Orchestration

Logging

The Api Gateway uses ILogger<ApiGatewayLog> to create logs.

In your Gateway API project, this can be used to tap into these logs.

Clients

The Api Gateway supports a fixed set of endpoints.

All routes go through these endpoints.

The Client application has to talk to these endpoints of the Api Gateway.

A Client library is provided for:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].