Fix #46 #55

Merged
alexis.drai merged 3 commits from api-gateway into master 2 years ago

@ -0,0 +1,15 @@
<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="Ocelot.Cache.CacheManager" Version="18.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
</Project>

@ -0,0 +1,37 @@
using Ocelot.Cache.CacheManager;
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)
.AddCacheManager(x =>
{
x.WithDictionaryHandle();
});
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,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:17820",
"sslPort": 44370
}
},
"profiles": {
"ApiGateway": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:5003;http://localhost:5197",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

@ -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,132 @@
{
"GlobalConfiguration": {
"BaseUrl": "https://localhost:5003"
},
"Routes": [
{
"UpstreamPathTemplate": "/gateway/cats",
"UpstreamHttpMethod": [ "Get" ],
"DownstreamPathTemplate": "/api/cats",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 7229
}
],
"RateLimitOptions": {
"EnableRateLimiting": true,
"Period": "1s",
"PeriodTimespan": 1,
"Limit": 1
}
},
{
"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" ],
"DownstreamPathTemplate": "/api/bars",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 7229
}
],
"RateLimitOptions": {
"EnableRateLimiting": true,
"Period": "1s",
"PeriodTimespan": 1,
"Limit": 1
}
},
{
"UpstreamPathTemplate": "/gateway/bars",
"UpstreamHttpMethod": [ "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" ],
"DownstreamPathTemplate": "/api/customers",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 7229
}
],
"FileCacheOptions": {
"TtlSeconds": 10
}
},
{
"UpstreamPathTemplate": "/gateway/customers",
"UpstreamHttpMethod": [ "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
}
]
}
]
}

@ -5,7 +5,9 @@ VisualStudioVersion = 17.2.32616.157
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "cat_cafe", "cat_cafe.csproj", "{CC02D05A-3817-4D0A-8766-3FEE0C90941B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "..\Tests\Tests.csproj", "{039A9A95-25ED-4632-9C4B-0AB4E5B5A7B4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "..\Tests\Tests.csproj", "{039A9A95-25ED-4632-9C4B-0AB4E5B5A7B4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiGateway", "..\ApiGateway\ApiGateway.csproj", "{18B6DE0C-D6D7-452F-94A2-83DB98194D6F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -21,6 +23,10 @@ Global
{039A9A95-25ED-4632-9C4B-0AB4E5B5A7B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{039A9A95-25ED-4632-9C4B-0AB4E5B5A7B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{039A9A95-25ED-4632-9C4B-0AB4E5B5A7B4}.Release|Any CPU.Build.0 = Release|Any CPU
{18B6DE0C-D6D7-452F-94A2-83DB98194D6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{18B6DE0C-D6D7-452F-94A2-83DB98194D6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18B6DE0C-D6D7-452F-94A2-83DB98194D6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18B6DE0C-D6D7-452F-94A2-83DB98194D6F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Loading…
Cancel
Save