Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Burgyn/MMLib.Ocelot.Provider.AppConfiguration
https://github.com/Burgyn/MMLib.Ocelot.Provider.AppConfiguration
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/Burgyn/MMLib.Ocelot.Provider.AppConfiguration
- Owner: Burgyn
- License: mit
- Created: 2020-02-22T19:02:24.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-25T05:02:52.000Z (about 1 year ago)
- Last Synced: 2024-04-26T17:23:11.790Z (8 months ago)
- Language: C#
- Size: 95.7 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-ocelot - AppConfiguration provider brings the possibility to divide the routing configuration from the service address definition.
README
# MMLib.Ocelot.Provider.AppConfiguration
![logo](/src/MMLib.Ocelot.Provider.AppConfiguration/icon.png)
***AppConfiguration*** provider brings the possibility to divide the routing configuration from the service address definition.
![Master](https://github.com/Burgyn/MMLib.Ocelot.Provider.AppConfiguration/workflows/Publish%20package/badge.svg)# Get Started
1. Define routing configuration
```json
"Routes": [
{
"DownstreamPathTemplate": "/api/users",
"ServiceName": "authorization",
"UpstreamPathTemplate": "/organizations/{organizationId}/users",
"SwaggerKey": "UsersKey"
},
{
"DownstreamPathTemplate": "/api/users/{everything}",
"ServiceName": "authorization",
"UpstreamPathTemplate": "/organizations/{organizationId}/users/{everything}",
"SwaggerKey": "PermissionsKey"
},
{
"DownstreamPathTemplate": "/api/permissions",
"ServiceName": "authorization",
"UpstreamPathTemplate": "/organizations/{organizationId}/permissions",
"SwaggerKey": "PermissionsKey"
},
{
"DownstreamPathTemplate": "/api/permissions/{everything}",
"ServiceName": "authorization",
"UpstreamPathTemplate": "/organizations/{organizationId}/permissions/{everything}",
"SwaggerKey": "PermissionsKey"
},
{
"DownstreamPathTemplate": "/api/todos",
"ServiceName": "toDos",
"UpstreamPathTemplate": "/organizations/{organizationId}/todos",
"SwaggerKey": "TodosKey"
},
{
"DownstreamPathTemplate": "/api/todos/{everything}",
"ServiceName": "toDos",
"UpstreamPathTemplate": "/organizations/{organizationId}/todos/{everything}",
"SwaggerKey": "TodosKey"
},
{
"DownstreamPathTemplate": "/api/organizations",
"ServiceName": "organizations",
"UpstreamPathTemplate": "/organizations",
"SwaggerKey": "OrganizationsKey"
},
{
"DownstreamPathTemplate": "/api/organizations/{everything}",
"ServiceName": "organizations",
"UpstreamPathTemplate": "/organizations/{everything}",
"SwaggerKey": "OrganizationsKey"
}
]
```3. Define services addresses in `appsettings.json`
```json
"Services": {
"organizations": {
"DownstreamPath": "http://localhost:9003"
},
"authorization": {
"DownstreamPath": "http://localhost:9002"
},
"toDos": {
"DownstreamPath": "http://localhost:9001"
}
}
```4. Define Service Discovery provider
```json
"GlobalConfiguration": {
"ServiceDiscoveryProvider": {
"Type": "AppConfiguration",
"PollingIntervalSeconds": 10000
}
}
```3. Add AppConfiguration provider in `Startup.cs`
> dotnet add package MMLib.Ocelot.Provider.AppConfiguration
```CSharp
services.AddOcelot()
.AddAppConfiguration();
```## Polling
This provider from optimization reason cache services 5 minutes by default. If you want change or turn off this caching, then set `PollingInterval` in provider definition (miliseconds).
## Change services definition section name
If you want change default section name, than you can set property `AppConfigurationSectionName` in provider definition.
```json
"GlobalConfiguration": {
"ServiceDiscoveryProvider": {
"Type": "AppConfiguration",
"PollingIntervalSeconds": 10000,
"AppConfigurationSectionName": "ApiServices"
}
}