changed to json configuration to get rid of yaml imports

This commit is contained in:
TomPallister
2016-11-02 21:50:53 +00:00
parent 190e394011
commit f4acb4f041
33 changed files with 386 additions and 356 deletions

View File

@ -16,7 +16,7 @@ namespace Ocelot.ManualTest
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddYamlFile("configuration.yaml")
.AddJsonFile("configuration.json")
.AddEnvironmentVariables();
Configuration = builder.Build();
@ -27,7 +27,7 @@ namespace Ocelot.ManualTest
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddOcelotYamlConfiguration(Configuration);
services.AddOcelotFileConfiguration(Configuration);
services.AddOcelot();
}

View File

@ -0,0 +1,81 @@
{
"ReRoutes": [
{
"DownstreamTemplate": "http://localhost:52876/",
"UpstreamTemplate": "/identityserverexample",
"UpstreamHttpMethod": "Get",
"AuthenticationOptions": {
"Provider": "IdentityServer",
"ProviderRootUrl": "http://localhost:52888",
"ScopeName": "api",
"AdditionalScopes": [
"openid",
"offline_access"
],
"ScopeSecret": "secret"
},
"AddHeadersToRequest": {
"CustomerId": "Claims[CustomerId] > value",
"LocationId": "Claims[LocationId] > value",
"UserType": "Claims[sub] > value[0] > |",
"UserId": "Claims[sub] > value[1] > |"
},
"AddClaimsToRequest": {
"CustomerId": "Claims[CustomerId] > value",
"LocationId": "Claims[LocationId] > value",
"UserType": "Claims[sub] > value[0] > |",
"UserId": "Claims[sub] > value[1] > |"
},
"AddQueriesToRequest": {
"CustomerId": "Claims[CustomerId] > value",
"LocationId": "Claims[LocationId] > value",
"UserType": "Claims[sub] > value[0] > |",
"UserId": "Claims[sub] > value[1] > |"
},
"RouteClaimsRequirement": {
"UserType": "registered"
},
"RequestIdKey": "OcRequestId"
},
{
"DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts",
"UpstreamTemplate": "/posts",
"UpstreamHttpMethod": "Get"
},
{
"DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts/{postId}",
"UpstreamTemplate": "/posts/{postId}",
"UpstreamHttpMethod": "Get"
},
{
"DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts/{postId}/comments",
"UpstreamTemplate": "/posts/{postId}/comments",
"UpstreamHttpMethod": "Get"
},
{
"DownstreamTemplate": "http://jsonplaceholder.typicode.com/comments",
"UpstreamTemplate": "/comments",
"UpstreamHttpMethod": "Get"
},
{
"DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts",
"UpstreamTemplate": "/posts",
"UpstreamHttpMethod": "Post"
},
{
"DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts/{postId}",
"UpstreamTemplate": "/posts/{postId}",
"UpstreamHttpMethod": "Put"
},
{
"DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts/{postId}",
"UpstreamTemplate": "/posts/{postId}",
"UpstreamHttpMethod": "Patch"
},
{
"DownstreamTemplate": "http://jsonplaceholder.typicode.com/posts/{postId}",
"UpstreamTemplate": "/posts/{postId}",
"UpstreamHttpMethod": "Delete"
}
]
}

View File

@ -1,88 +0,0 @@
ReRoutes:
# The url we are forwarding the request to
- DownstreamTemplate: http://localhost:52876/
# The path we are listening on for this re route
UpstreamTemplate: /identityserverexample
# The method we are listening for on this re route
UpstreamHttpMethod: Get
# Only support identity server at the moment
AuthenticationOptions:
Provider: IdentityServer
ProviderRootUrl: http://localhost:52888
ScopeName: api
AdditionalScopes:
- openid
- offline_access
# Required if using reference tokens
ScopeSecret: secret
# WARNING - will overwrite any headers already in the request with these values.
# Ocelot will look in the user claims for the key in [] then return the value and save
# it as a header with the given key before the colon (:). The index selection on value
# means that Ocelot will use the delimiter specified after the next > to split the
# claim value and return the index specified.
AddHeadersToRequest:
CustomerId: Claims[CustomerId] > value
LocationId: Claims[LocationId] > value
UserType: Claims[sub] > value[0] > |
UserId: Claims[sub] > value[1] > |
# WARNING - will overwrite any claims already in the request with these values.
# Ocelot will look in the user claims for the key in [] then return the value and save
# it as a claim with the given key before the colon (:). The index selection on value
# means that Ocelot will use the delimiter specified after the next > to split the
# claim value and return the index specified.
AddClaimsToRequest:
CustomerId: Claims[CustomerId] > value
LocationId: Claims[LocationId] > value
UserType: Claims[sub] > value[0] > |
UserId: Claims[sub] > value[1] > |
# WARNING - will overwrite any query string entries already in the request with these values.
# Ocelot will look in the user claims for the key in [] then return the value and save
# it as a query string with the given key before the colon (:). The index selection on value
# means that Ocelot will use the delimiter specified after the next > to split the
# claim value and return the index specified.
AddQueriesToRequest:
CustomerId: Claims[CustomerId] > value
LocationId: Claims[LocationId] > value
UserType: Claims[sub] > value[0] > |
UserId: Claims[sub] > value[1] > |
# This specifies any claims that are required for the user to access this re route.
# In this example the user must have the claim type UserType and
# the value must be registered
RouteClaimsRequirement:
UserType: registered
# This tells Ocelot to look for a header and use its value as a request/correlation id.
# If it is set here then the id will be forwarded to the downstream service. If it
# does not then it will not be forwarded
RequestIdKey: OcRequestId
# The next re route...
- DownstreamTemplate: http://jsonplaceholder.typicode.com/posts
UpstreamTemplate: /posts
UpstreamHttpMethod: Get
# The next re route...
- DownstreamTemplate: http://jsonplaceholder.typicode.com/posts/{postId}
UpstreamTemplate: /posts/{postId}
UpstreamHttpMethod: Get
# The next re route...
- DownstreamTemplate: http://jsonplaceholder.typicode.com/posts/{postId}/comments
UpstreamTemplate: /posts/{postId}/comments
UpstreamHttpMethod: Get
# The next re route...
- DownstreamTemplate: http://jsonplaceholder.typicode.com/comments
UpstreamTemplate: /comments
UpstreamHttpMethod: Get
# The next re route...
- DownstreamTemplate: http://jsonplaceholder.typicode.com/posts
UpstreamTemplate: /posts
UpstreamHttpMethod: Post
# The next re route...
- DownstreamTemplate: http://jsonplaceholder.typicode.com/posts/{postId}
UpstreamTemplate: /posts/{postId}
UpstreamHttpMethod: Put
# The next re route...
- DownstreamTemplate: http://jsonplaceholder.typicode.com/posts/{postId}
UpstreamTemplate: /posts/{postId}
UpstreamHttpMethod: Patch
# The next re route...
- DownstreamTemplate: http://jsonplaceholder.typicode.com/posts/{postId}
UpstreamTemplate: /posts/{postId}
UpstreamHttpMethod: Delete

View File

@ -17,8 +17,7 @@
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"NetEscapades.Configuration.Yaml": "1.2.0"
}
},
"tools": {
@ -28,8 +27,6 @@
"frameworks": {
"netcoreapp1.4": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
@ -39,8 +36,7 @@
"preserveCompilationContext": true,
"copyToOutput": {
"include": [
"middlewareConfiguration.yaml",
"configuration.yaml"
"configuration.json"
]
}
},
@ -58,8 +54,7 @@
"Areas/**/Views",
"appsettings.json",
"web.config",
"middlewareConfiguration.yaml",
"configuration.yaml"
"configuration.json"
]
},