Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eShopOnAbp: Introduce ocelot.json #80

Merged
merged 5 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ kind: ConfigMap
metadata:
name: {{ .Release.Name }}-{{ .Chart.Name }}-configmap
data:
appsettings.json: |-
ocelot.json: |-
{
"GlobalConfiguration": {
"BaseUrl": "{{ .Values.config.globalConfigurationBaseUrl }}"
},
"Routes": [
{
"ServiceKey": "Identity Service",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ spec:
containerPort: 443
volumeMounts:
- name: config-volume
mountPath: /app/appsettings.json
subPath: appsettings.json
mountPath: /app/ocelot.json
subPath: ocelot.json
env:
- name: App__SelfUrl
value: "{{ .Values.config.selfUrl }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ kind: ConfigMap
metadata:
name: {{ .Release.Name }}-{{ .Chart.Name }}-configmap
data:
appsettings.json: |-
ocelot.json: |-
{
"GlobalConfiguration": {
"BaseUrl": "{{ .Values.config.globalConfigurationBaseUrl }}"
},
"Routes": [
{
"ServiceKey": "Identity Service",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ spec:
containerPort: 443
volumeMounts:
- name: config-volume
mountPath: /app/appsettings.json
subPath: appsettings.json
mountPath: /app/ocelot.json
subPath: ocelot.json
env:
- name: App__SelfUrl
value: "{{ .Values.config.selfUrl }}"
Expand Down
15 changes: 13 additions & 2 deletions gateways/web-public/src/EShopOnAbp.WebPublicGateway/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace EShopOnAbp.WebPublicGateway;

Expand All @@ -17,10 +19,19 @@ public static async Task<int> Main(string[] args)
try
{
Log.Information($"Starting {assemblyName}.");
var app = await ApplicationBuilderHelper.BuildApplicationAsync<EShopOnAbpWebPublicGatewayModule>(args);

var builder = WebApplication.CreateBuilder(args);
builder.Host
.AddAppSettingsSecretsJson()
.AddOcelotJson()
.UseAutofac()
.UseSerilog();

await builder.AddApplicationAsync<EShopOnAbpWebPublicGatewayModule>();
var app = builder.Build();
await app.InitializeApplicationAsync();
await app.RunAsync();

return 0;
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,104 +17,7 @@
}
},
"AllowedHosts": "*",
"Routes": [
{
"ServiceKey": "Account Service",
"DownstreamPathTemplate": "/api/account/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44330
}
],
"UpstreamPathTemplate": "/api/account/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/abp/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/abp/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ],
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 3000,
"TimeoutValue": 2500
}
},
{
"ServiceKey": "Catalog Service",
"DownstreamPathTemplate": "/api/catalog/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44354
}
],
"UpstreamPathTemplate": "/api/catalog/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ],
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 3000,
"TimeoutValue": 2500
}
},
{
"ServiceKey": "Basket Service",
"DownstreamPathTemplate": "/api/basket/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44355
}
],
"UpstreamPathTemplate": "/api/basket/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ],
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 3000,
"TimeoutValue": 2500
}
},
{
"ServiceKey": "Ordering Service",
"DownstreamPathTemplate": "/api/ordering/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44356
}
],
"UpstreamPathTemplate": "/api/ordering/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Payment Service",
"DownstreamPathTemplate": "/api/payment/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44357
}
],
"UpstreamPathTemplate": "/api/payment/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
}
],
"GlobalConfiguration": {
"BaseUrl": "https://localhost:44373"
},

"Redis": {
"Configuration": "localhost:6379"
},
Expand Down
100 changes: 100 additions & 0 deletions gateways/web-public/src/EShopOnAbp.WebPublicGateway/ocelot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"GlobalConfiguration": {
"BaseUrl": "https://localhost:44373"
},
"Routes": [
{
"ServiceKey": "Account Service",
"DownstreamPathTemplate": "/api/account/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44330
}
],
"UpstreamPathTemplate": "/api/account/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/abp/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/abp/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ],
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 3000,
"TimeoutValue": 2500
}
},
{
"ServiceKey": "Catalog Service",
"DownstreamPathTemplate": "/api/catalog/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44354
}
],
"UpstreamPathTemplate": "/api/catalog/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ],
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 3000,
"TimeoutValue": 2500
}
},
{
"ServiceKey": "Basket Service",
"DownstreamPathTemplate": "/api/basket/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44355
}
],
"UpstreamPathTemplate": "/api/basket/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ],
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 3000,
"TimeoutValue": 2500
}
},
{
"ServiceKey": "Ordering Service",
"DownstreamPathTemplate": "/api/ordering/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44356
}
],
"UpstreamPathTemplate": "/api/ordering/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceKey": "Payment Service",
"DownstreamPathTemplate": "/api/payment/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44357
}
],
"UpstreamPathTemplate": "/api/payment/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
}
]
}
14 changes: 12 additions & 2 deletions gateways/web/src/EShopOnAbp.WebGateway/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace EShopOnAbp.WebGateway;

Expand All @@ -17,10 +19,18 @@ public static async Task<int> Main(string[] args)
try
{
Log.Information($"Starting {assemblyName}.");
var app = await ApplicationBuilderHelper.BuildApplicationAsync<EShopOnAbpWebGatewayModule>(args);
var builder = WebApplication.CreateBuilder(args);
builder.Host
.AddAppSettingsSecretsJson()
.AddOcelotJson()
.UseAutofac()
.UseSerilog();

await builder.AddApplicationAsync<EShopOnAbpWebGatewayModule>();
var app = builder.Build();
await app.InitializeApplicationAsync();
await app.RunAsync();

return 0;
}
catch (Exception ex)
Expand Down
Loading