Skip to content

VishwamKumar/api-gateway.rest-apis.examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ApiGatewayApps

Description

This repository demonstrates how to build API Gateways using two different .NET technologies:

  • ApiGateway.Ocelot.RestApi – Implements a gateway using Ocelot, a lightweight API gateway library for .NET.
  • ApiGateway.Yarp.RestApi – Implements a gateway using YARP (Yet Another Reverse Proxy), a modern, high-performance reverse proxy from Microsoft.

Both projects show how to route multiple REST APIs through a single gateway endpoint and support multiple downstream services.


Author

Vishwa Kumar

Vishwa is the primary developer and architect of this example app, responsible for the architecture and implementation of these features.

License

This project is licensed under the MIT License - see the LICENSE file for details.

✅ Features

  • Centralized routing for multiple REST APIs
  • Aggregated Swagger UI (in YARP)
  • Easily extendable to support more downstream services
  • Minimal configuration required to onboard new APIs

Ocelot Gateway

Ocelot is configured via ocelot.json and uses route-based forwarding to downstream services. Swagger endpoints are aggregated using the SwaggerKey and SwaggerEndPoints config.

  • Example upstream routes:
    • /apiaudit/api/{everything}https://restaudit.azurewebsites.net/api/{everything}
    • /hourtracker/api/{everything}https://hourtrackerrest.azurewebsites.net/api/{everything}

YARP Gateway

YARP is configured via appsettings.json and uses a declarative model for routes and clusters. Swagger UI is hosted centrally in the gateway and proxies each downstream's Swagger JSON.

  • Swagger UI available at: https://localhost:7153/swagger/index.html
  • Example upstream routes:
    • /apiaudit/api/{*}https://restaudit.azurewebsites.net/api/{*}
    • /hourtracker/api/{*}https://hourtrackerrest.azurewebsites.net/api/{*}
  • Aggregated Swagger JSONs:
    • /apiaudit/swagger/v1/swagger.json
    • /hourtracker/swagger/v1/swagger.json

Getting Started

Prerequisites

  • .NET SDK 9.0 or later
  • Visual Studio or VS Code
  • Two backend REST APIs (or mock endpoints)

Run Ocelot Gateway

dotnet run --project ApiGateway.Ocelot.RestApi

About

Implementation of Gateway Service Consuming Multiple REST APIs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages