Giter VIP home page Giter VIP logo

ntrada's Introduction

    / | / / /__________ _____/ /___ _
   /  |/ / __/ ___/ __ `/ __  / __ `/
  / /|  / /_/ /  / /_/ / /_/ / /_/ / 
 /_/ |_/\__/_/   \__,_/\__,_/\__,_/

 /___ 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.

Features:

  • 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

Extensions:

  • 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: home
  routes:
  - upstream: /
    method: GET
    use: return_value
    return_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:

public class Program
{
    public static Task Main(string[] args)
        => CreateHostBuilder(args).Build().RunAsync();

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.ConfigureAppConfiguration(builder =>
                {
                    var configPath = 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: true
  global: false
  claims:
    role: http://schemas.microsoft.com/ws/2008/06/identity/claims/role

http:
  retries: 2
  interval: 2.0
  exponential: true

useErrorHandler: true
useJaeger: true
useForwardedHeaders: true
passQueryString: true
modulesPath: Modules
payloadsFolder: Payloads
forwardRequestHeaders: true
forwardResponseHeaders: true
generateRequestId: true
generateTraceId: true
resourceId:
  generate: true
  property: id
useLocalUrl: true
loadBalancer:
  enabled: false
  url: localhost:9999

extensions:
  customErrors:
    includeExceptionMessage: true
  
  cors:
    allowCredentials: true
    allowedOrigins:
      - '*'
    allowedMethods:
      - post
      - delete
    allowedHeaders:
      - '*'
    exposedHeaders:
      - Request-ID
      - Resource-ID
      - Trace-ID
      - Total-Count
    
  jwt:
    key: eiquief5phee9pazo0Faegaez9gohThailiur5woy2befiech1oarai4aiLi6ahVecah3ie9Aiz6Peij
    issuer: ntrada
    issuers:
    validateIssuer: true
    audience:
    audiences:
    validateAudience: false
    validateLifetime: true
    
  rabbitmq:
    enabled: true
    connectionName: ntrada
    hostnames:
      - localhost
    port: 5672
    virtualHost: /
    username: guest
    password: guest
    requestedConnectionTimeout: 3000
    socketReadTimeout: 3000
    socketWriteTimeout: 3000
    requestedHeartbeat: 60
    exchange:
      declareExchange: true
      durable: true
      autoDelete: false
      type: topic
    messageContext:
      enabled: true
      header: message_context
    logger:
      enabled: true
    spanContextHeader: span_context

  tracing:
    serviceName: ntrada
    udpHost: localhost
    udpPort: 6831
    maxPacketSize: 0
    sampler: const
    useEmptyTracer: false

modules:
  home:
    routes:
      - upstream: /
        method: GET
        use: return_value
        returnValue: Welcome to Ntrada API!
        
      - upstream: /
        method: POST
        auth: false
        use: rabbitmq
        config:
          exchange: sample.exchange
          routing_key: sample.routing.key

  orders:
    routes:
      - upstream: /orders
        methods:
          - GET
          - POST
          - DELETE
        matchAll: true
        use: downstream
        downstream: orders-service/orders
          
    services:
      orders-service:
        localUrl: localhost:5001
        url: orders-service

ntrada's People

Contributors

spetz avatar goorion avatar gioxoay avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.