Compare commits
3 Commits
0efb035d12
...
cbd3accf72
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cbd3accf72 | ||
|
|
d108978b63 | ||
|
|
6a536e950d |
@@ -10,6 +10,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="NLog" Version="5.4.0" />
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.4.0" />
|
||||||
|
<PackageReference Include="NLog.Web.AspNetCore" Version="5.4.0" />
|
||||||
<PackageReference Include="Ocelot" Version="22.0.1" />
|
<PackageReference Include="Ocelot" Version="22.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
53
Program.cs
53
Program.cs
@@ -1,26 +1,41 @@
|
|||||||
|
using NLog;
|
||||||
|
using NLog.Web;
|
||||||
using Ocelot.DependencyInjection;
|
using Ocelot.DependencyInjection;
|
||||||
using Ocelot.Middleware;
|
using Ocelot.Middleware;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||||
|
logger.Info("Logging initialized.");
|
||||||
|
|
||||||
// Make sure to add the Ocelot configuration file
|
try
|
||||||
builder.Configuration.AddJsonFile("ocelot.json");
|
|
||||||
|
|
||||||
// Add Ocelot services
|
|
||||||
builder.Services.AddOcelot();
|
|
||||||
|
|
||||||
var app = builder.Build();
|
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
|
||||||
app.UseRouting();
|
|
||||||
app.UseAuthorization();
|
|
||||||
|
|
||||||
// Use Ocelot middleware in an appropriate way
|
|
||||||
app.UseEndpoints(endpoints =>
|
|
||||||
{
|
{
|
||||||
endpoints.MapControllers();
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
});
|
|
||||||
|
|
||||||
app.UseOcelot().Wait();
|
// Make sure to add the Ocelot configuration file
|
||||||
|
var suffix = builder.Environment.IsDevelopment() ? ".Development" : "";
|
||||||
|
builder.Configuration.AddJsonFile($"ocelot{suffix}.json");
|
||||||
|
|
||||||
app.Run();
|
// Add Ocelot services
|
||||||
|
builder.Services.AddOcelot();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
app.UseRouting();
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
// Use Ocelot middleware in an appropriate way
|
||||||
|
app.UseEndpoints(endpoints =>
|
||||||
|
{
|
||||||
|
endpoints.MapControllers();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.UseOcelot().Wait();
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
logger.Error(ex, "Stopped program because of exception.");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
@@ -5,5 +5,48 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"NLog": {
|
||||||
|
"throwConfigExceptions": true,
|
||||||
|
"variables": {
|
||||||
|
"logDirectory": "E:\\LogFiles\\Digital Data\\workFlow.Gateway",
|
||||||
|
"logFileNamePrefix": "${shortdate}-workFlow.Gateway"
|
||||||
|
},
|
||||||
|
"targets": {
|
||||||
|
"infoLogs": {
|
||||||
|
"type": "File",
|
||||||
|
"fileName": "${logDirectory}\\${logFileNamePrefix}-Info.log",
|
||||||
|
"maxArchiveDays": 30
|
||||||
|
},
|
||||||
|
"errorLogs": {
|
||||||
|
"type": "File",
|
||||||
|
"fileName": "${logDirectory}\\${logFileNamePrefix}-Error.log",
|
||||||
|
"maxArchiveDays": 30
|
||||||
|
},
|
||||||
|
"criticalLogs": {
|
||||||
|
"type": "File",
|
||||||
|
"fileName": "${logDirectory}\\${logFileNamePrefix}-Critical.log",
|
||||||
|
"maxArchiveDays": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Trace, Debug, Info, Warn, Error and *Fatal*
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"logger": "*",
|
||||||
|
"minLevel": "Info",
|
||||||
|
"maxLevel": "Warn",
|
||||||
|
"writeTo": "infoLogs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"logger": "*",
|
||||||
|
"level": "Error",
|
||||||
|
"writeTo": "errorLogs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"logger": "*",
|
||||||
|
"level": "Fatal",
|
||||||
|
"writeTo": "criticalLogs"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
96
ocelot.Development.json
Normal file
96
ocelot.Development.json
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
{
|
||||||
|
"Routes": [
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/swagger/{route}",
|
||||||
|
"DownstreamScheme": "http",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 9090
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/swagger/auth/{route}",
|
||||||
|
"UpstreamHttpMethod": [
|
||||||
|
"Get"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/swagger/{route}",
|
||||||
|
"DownstreamScheme": "http",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 8088
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/swagger/{route}",
|
||||||
|
"UpstreamHttpMethod": [
|
||||||
|
"Get"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/Auth/{route}",
|
||||||
|
"DownstreamScheme": "http",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 8088
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/Auth/{route}",
|
||||||
|
"UpstreamHttpMethod": [
|
||||||
|
"Get",
|
||||||
|
"Post"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/Auth/login/{id}",
|
||||||
|
"DownstreamScheme": "http",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 8088
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/Auth/login/{id}",
|
||||||
|
"UpstreamHttpMethod": [
|
||||||
|
"Post"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/{route}",
|
||||||
|
"DownstreamScheme": "http",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 8088
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/{route}",
|
||||||
|
"UpstreamHttpMethod": [
|
||||||
|
"Get",
|
||||||
|
"Post",
|
||||||
|
"Put",
|
||||||
|
"Delete"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/{route}/{id}",
|
||||||
|
"DownstreamScheme": "http",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 8088
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/{route}{id}",
|
||||||
|
"UpstreamHttpMethod": [
|
||||||
|
"Get",
|
||||||
|
"Delete"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"GlobalConfiguration": {
|
||||||
|
"BaseUrl": "https://localhost:7052"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user