Coder Social home page Coder Social logo

kongregister's Introduction

Logo

KongRegister

License NuGet version Travis build (release) Travis build (develop)

Register your .Net Core web-service in Kong API Gateway on startup and unregister them when you application is shutting down.

Getting started

Install KongRegister package :

Install-Package KongRegister

Add the following configuration in your appsettings.json :

"KongRegister": {
    "KongApiUrl": "http://YourKongApiUrl:8081",
    "KongApiKeyHeader": "YourApikeyHeader",
    "KongApiKey": "YourApiKey",
    "UpstreamId": "YourUpstreamId",
    "TargetHostDiscovery": "dynamic",
    "TargetHost": "YourTargetHostNameOrIp",
    "TargetPortDiscovery": "dynamic",
    "TargetPort": 5000,
    "TargetWeight": 1000
  }

Add the reference in your Startup class :

using KongRegister;

Add those two services in the ConfigureServices method :

public void ConfigureServices(IServiceCollection services)
{
    services.Configure<KongRegisterConfig>(Configuration.GetSection("KongRegister"));
    services.AddSingleton<IHostedService, KongRegisterService>();
    ...
}

Run your application, OK it's registered in your Kong server !
Shutdown it, it's now unregistered from Kong !

Compatibility

KongRegister is compatible with:

  • Kong CE 0.12.x, 0.13.0
  • .Net Core 2.0

Prerequisites

  • A running Kong installation
  • A .Net Core 2.0 web application

Discussions & Support

You can get help via the issue tracker here on GitHub

Features

  • Auto register in Kong server on startup
  • Auto unregister from Kong server on shutdown
  • Auto discover host IP
  • Auto discover host port

Installation

You must install KongRegister from NuGet.

Package manager :

Install-Package KongRegister

.Net CLI :

dotnet add package KongRegister

Configuration

The configuration must be define in the appsettings.json under a root section that you can named it as you choice.

Example :

"KongRegister": {
    "KongApiUrl": "http://YourKongApiUrl:8081",
    "KongApiKeyHeader": "YourApikeyHeader",
    "KongApiKey": "YourApiKey",
    "UpstreamId": "YourUpstreamId",
    "TargetHostDiscovery": "dynamic",
    "TargetHost": "YourTargetHostNameOrIp",
    "TargetPortDiscovery": "dynamic",
    "TargetPort": 5000,
    "TargetWeight": 1000
  }

See below all detailed parameters :

Parameter Type Description
KongApiUrl String Url of your Kong Admin Api. Don't forget the port if it's not standard (80 or 443)
KongApiKeyHeader String Name of your header that contain your API Key (if your Kong server is secured).
KongApiKey String Your API Key (if your Kong server is secured).
UpstreamId String Kong Upstream Id that you want to register your application into.
TargetHostDiscovery String Discovery method for your application host. Value must be dynamic or static
TargetHost String Host name or IP of your application host. (if discovery method is static)
TargetPortDiscovery String Discovery method for your application host port. Value must be dynamic or static
TargetPort Integer Port of your application host (if discovery method is static)
TargetWeight Integer Weight for the registered target in Kong server

Running

Todo

using KongRegister;

kongregister's People

Contributors

renardguill 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.