/ | / / /__________ _____/ /___ _
/ |/ / __/ ___/ __ `/ __ / __ `/
/ /| / /_/ / / /_/ / /_/ / /_/ / /_/ |_/\__/_/ \__,_/\__,_/\__,_/
/___ API Gateway (Entrance) ___/
Ntrada (entrada is a spanish word meaning an entrance).
The aim of this project is to provide an easily configurable (via YML) and extendable (e.g. RabbitMQ integration, OpenTracing etc.) API Gateway, that requires no coding whatsoever and can be started via Docker or as .NET Core application.
- Configuration via single file
- Separate modules definitions
- Static content
- Routing
- Match-all methods generic templates
- Request forwarding
- Headers forwarding
- Custom request bodies
- Request body validation
- Query string binding
- Request & response headers modification
- Basic request & response transformation
- Authentication
- Authorization
- HTTP retries
- Strongly-typed service names
- Extensibility with custom request handlers
- JWT
- RabbitMQ integration
- Open Tracing with Jaeger
- CORS
- Custom errors
No documentation yet, please take a look at the basic ntrada.yml configuration.
modules:
- name: homeroutes:
- upstream: /method: GETuse: return_valuereturn_value: Welcome to Ntrada API.Start via Docker:
docker build -t ntrada .
docker run -it --rm --name ntrada -p 5000:80 ntrada
curl localhost:5000
Or as .NET Core application:
cd src/Ntrada.Host/
dotnet run
curl localhost:5000
If you're willing to create your own application (instead of running it via Docker), it's all it takes to use Ntrada:
publicclassProgram{publicstaticTaskMain(string[]args)=>CreateHostBuilder(args).Build().RunAsync();publicstaticIHostBuilderCreateHostBuilder(string[]args)=>Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder =>{webBuilder.ConfigureAppConfiguration(builder =>{varconfigPath=args?.FirstOrDefault()??"ntrada.yml";builder.AddYamlFile(configPath,false);}).UseStartup<Startup>();});}More real-world examples (modules, asynchronous messaging, load balancing etc.) can be found in the following projects:
Advanced configuration
auth:
enabled: trueglobal: falseclaims:
role: http://schemas.microsoft.com/ws/2008/06/identity/claims/rolehttp:
retries: 2interval: 2.0exponential: trueuseErrorHandler: trueuseJaeger: trueuseForwardedHeaders: truepassQueryString: truemodulesPath: ModulespayloadsFolder: PayloadsforwardRequestHeaders: trueforwardResponseHeaders: truegenerateRequestId: truegenerateTraceId: trueresourceId:
generate: trueproperty: iduseLocalUrl: trueloadBalancer:
enabled: falseurl: localhost:9999extensions:
customErrors:
includeExceptionMessage: truecors:
allowCredentials: trueallowedOrigins:
- '*'allowedMethods:
- post
- deleteallowedHeaders:
- '*'exposedHeaders:
- Request-ID
- Resource-ID
- Trace-ID
- Total-Countjwt:
key: eiquief5phee9pazo0Faegaez9gohThailiur5woy2befiech1oarai4aiLi6ahVecah3ie9Aiz6Peijissuer: ntradaissuers:
validateIssuer: trueaudience:
audiences:
validateAudience: falsevalidateLifetime: truerabbitmq:
enabled: trueconnectionName: ntradahostnames:
- localhostport: 5672virtualHost: /username: guestpassword: guestrequestedConnectionTimeout: 3000socketReadTimeout: 3000socketWriteTimeout: 3000requestedHeartbeat: 60exchange:
declareExchange: truedurable: trueautoDelete: falsetype: topicmessageContext:
enabled: trueheader: message_contextlogger:
enabled: truespanContextHeader: span_contexttracing:
serviceName: ntradaudpHost: localhostudpPort: 6831maxPacketSize: 0sampler: constuseEmptyTracer: falsemodules:
home:
routes:
- upstream: /method: GETuse: return_valuereturnValue: Welcome to Ntrada API!
- upstream: /method: POSTauth: falseuse: rabbitmqconfig:
exchange: sample.exchangerouting_key: sample.routing.keyorders:
routes:
- upstream: /ordersmethods:
- GET
- POST
- DELETEmatchAll: trueuse: downstreamdownstream: orders-service/ordersservices:
orders-service:
localUrl: localhost:5001url: orders-service