✨ Add API Gateway (Ocelot)
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
da1b96cc22
commit
75aac77310
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Ocelot" Version="18.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,32 @@
|
||||
using Ocelot.DependencyInjection;
|
||||
using Ocelot.Middleware;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Configuration.AddJsonFile("ocelot.json", optional: false, reloadOnChange: true);
|
||||
builder.Services.AddOcelot(builder.Configuration);
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
await app.UseOcelot();
|
||||
|
||||
app.Run();
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
{
|
||||
"GlobalConfiguration": {
|
||||
"BaseUrl": "https://localhost:5003"
|
||||
},
|
||||
"Routes": [
|
||||
{
|
||||
"UpstreamPathTemplate": "/gateway/cats",
|
||||
"UpstreamHttpMethod": [ "Get" ],
|
||||
"DownstreamPathTemplate": "/api/cats",
|
||||
"DownstreamScheme": "https",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 7229
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"UpstreamPathTemplate": "/gateway/cats",
|
||||
"UpstreamHttpMethod": [ "Post" ],
|
||||
"DownstreamPathTemplate": "/api/cats",
|
||||
"DownstreamScheme": "https",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 7229
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"UpstreamPathTemplate": "/gateway/cats/{id}",
|
||||
"UpstreamHttpMethod": [ "Get", "Put", "Delete" ],
|
||||
"DownstreamPathTemplate": "/api/cats/{id}",
|
||||
"DownstreamScheme": "https",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 7229
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"UpstreamPathTemplate": "/gateway/bars",
|
||||
"UpstreamHttpMethod": [ "Get", "Post" ],
|
||||
"DownstreamPathTemplate": "/api/bars",
|
||||
"DownstreamScheme": "https",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 7229
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"UpstreamPathTemplate": "/gateway/bars/{id}",
|
||||
"UpstreamHttpMethod": [ "Get", "Put", "Delete" ],
|
||||
"DownstreamPathTemplate": "/api/bars/{id}",
|
||||
"DownstreamScheme": "https",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 7229
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"UpstreamPathTemplate": "/gateway/customers",
|
||||
"UpstreamHttpMethod": [ "Get", "Post" ],
|
||||
"DownstreamPathTemplate": "/api/customers",
|
||||
"DownstreamScheme": "https",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 7229
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"UpstreamPathTemplate": "/gateway/customers/{id}",
|
||||
"UpstreamHttpMethod": [ "Get", "Put", "Delete" ],
|
||||
"DownstreamPathTemplate": "/api/customers/{id}",
|
||||
"DownstreamScheme": "https",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 7229
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in new issue