KongRegister 3.0.0
dotnet add package KongRegister --version 3.0.0
NuGet\Install-Package KongRegister -Version 3.0.0
<PackageReference Include="KongRegister" Version="3.0.0" />
paket add KongRegister --version 3.0.0
#r "nuget: KongRegister, 3.0.0"
// Install KongRegister as a Cake Addin
#addin nuget:?package=KongRegister&version=3.0.0
// Install KongRegister as a Cake Tool
#tool nuget:?package=KongRegister&version=3.0.0
KongRegister
Register your AspNetCore web-service in Kong API Gateway on startup and unregister it when you application is shutting down.
Getting started
Install KongRegister package :
Install-Package KongRegister
Add the following configuration in your appsettings.json :
"KongRegister": {
"OnStartup" : true,
"KongApiUrl": "http://YourKongApiUrl:8081",
"KongApiKeyHeader": "YourApikeyHeader",
"KongApiKey": "YourApiKey",
"UpstreamId": "YourUpstreamId",
"TargetHostDiscovery": "dynamic",
"TargetPortDiscovery": "dynamic",
"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.ConfigureKongRegister(Configuration);
...
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseKongRegisterController();
...
}
Run your application, OK it's registered in your Kong server !<br/> Shutdown it, it's now unregistered from Kong !
Compatibility
KongRegister is compatible with:
- Kong CE 0.13.x, 0.14.x
- .Net Core 3.1
Prerequisites
- A running Kong installation
- A .Net Core 3.1 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
- Manual register in Kong via an HTTP request
- Manual unregister in Kong via an HTTP request
- 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": {
"OnStartup" : true,
"KongApiUrl": "http://YourKongApiUrl:8081",
"KongApiKeyHeader": "YourApikeyHeader",
"KongApiKey": "YourApiKey",
"UpstreamId": "YourUpstreamId",
"TargetHostDiscovery": "dynamic",
"TargetHost": "YourTargetHostNameOrIp",
"TargetPortDiscovery": "dynamic",
"TargetPort": 5000,
"TargetWeight": 1000
}
Or define in environments variables in uppercase and start with KR_
followed by a parameter name. Like KR_ONSTARTUP=True
.
See below all detailed parameters :
Parameter | Type | Description |
---|---|---|
Disabled |
Boolean |
Disble KongRegister service. |
OnStratup |
Boolean |
Enable registering on startup. |
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;
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Microsoft.AspNet.WebApi.Client (>= 5.2.7)
- Microsoft.AspNetCore.Hosting.Server.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Http.Features (>= 3.1.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 3.1.0)
- Microsoft.Extensions.Logging.Abstractions (>= 3.1.0)
- Microsoft.Extensions.Options (>= 3.1.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 3.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
KongRegister v3.0.0
Migrate to dotnet core 3.1