12 changed files with 302 additions and 3 deletions
@ -0,0 +1,32 @@ |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|||
# Visual Studio Version 16 |
|||
VisualStudioVersion = 16.0.31320.298 |
|||
MinimumVisualStudioVersion = 10.0.40219.1 |
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{138BBFFC-09B9-49FB-9C57-E25327CCE0C1}" |
|||
EndProject |
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{A5E7F07B-7A5D-416D-A9E0-2009A48CBE2A}" |
|||
EndProject |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EShopOnAbp.WebPublicGateway", "src\EShopOnAbp.WebPublicGateway\EShopOnAbp.WebPublicGateway.csproj", "{C3A2AC7A-A50C-4C80-BE68-7FBBAD09D981}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Release|Any CPU = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{C3A2AC7A-A50C-4C80-BE68-7FBBAD09D981}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{C3A2AC7A-A50C-4C80-BE68-7FBBAD09D981}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{C3A2AC7A-A50C-4C80-BE68-7FBBAD09D981}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{C3A2AC7A-A50C-4C80-BE68-7FBBAD09D981}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(SolutionProperties) = preSolution |
|||
HideSolutionNode = FALSE |
|||
EndGlobalSection |
|||
GlobalSection(NestedProjects) = preSolution |
|||
{C3A2AC7A-A50C-4C80-BE68-7FBBAD09D981} = {138BBFFC-09B9-49FB-9C57-E25327CCE0C1} |
|||
EndGlobalSection |
|||
GlobalSection(ExtensibilityGlobals) = postSolution |
|||
SolutionGuid = {1753A143-A9EF-43ED-970D-C71BAD179AE6} |
|||
EndGlobalSection |
|||
EndGlobal |
|||
@ -0,0 +1,13 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
|
|||
namespace EShopOnAbp.WebPublicGateway.Controllers |
|||
{ |
|||
public class HomeController : AbpController |
|||
{ |
|||
public ActionResult Index() |
|||
{ |
|||
return Redirect("/swagger"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Account.HttpApi" Version="4.3.3" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\..\shared\EShopOnAbp.Shared.Hosting.Gateways\EShopOnAbp.Shared.Hosting.Gateways.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Remove="Logs\**" /> |
|||
<Content Remove="Logs\**" /> |
|||
<EmbeddedResource Remove="Logs\**" /> |
|||
<None Remove="Logs\**" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,67 @@ |
|||
using System.Collections.Generic; |
|||
using EShopOnAbp.Shared.Hosting.Gateways; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Ocelot.Middleware; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Account; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace EShopOnAbp.WebPublicGateway |
|||
{ |
|||
[DependsOn( |
|||
typeof(EShopOnAbpSharedHostingGatewaysModule), |
|||
typeof(AbpAccountHttpApiModule) |
|||
)] |
|||
public class EShopOnAbpWebPublicGatewayModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var configuration = context.Services.GetConfiguration(); |
|||
var hostingEnvironment = context.Services.GetHostingEnvironment(); |
|||
|
|||
SwaggerWithAuthConfigurationHelper.Configure( |
|||
context: context, |
|||
authority: configuration["AuthServer:Authority"], |
|||
scopes: new Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */ |
|||
{ |
|||
}, |
|||
apiTitle: "WebPublic Gateway API" |
|||
); |
|||
} |
|||
|
|||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|||
{ |
|||
var app = context.GetApplicationBuilder(); |
|||
var env = context.GetEnvironment(); |
|||
|
|||
if (env.IsDevelopment()) |
|||
{ |
|||
app.UseDeveloperExceptionPage(); |
|||
} |
|||
|
|||
app.UseCorrelationId(); |
|||
app.UseSwagger(); |
|||
app.UseSwaggerUI(options => |
|||
{ |
|||
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Web Public Gateway API"); |
|||
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>(); |
|||
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); |
|||
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); |
|||
}); |
|||
app.UseAbpSerilogEnrichers(); |
|||
app.MapWhen( |
|||
ctx => ctx.Request.Path.ToString().StartsWith("/api/abp/api-definition") || |
|||
ctx.Request.Path.ToString().TrimEnd('/').Equals(""), |
|||
app2 => |
|||
{ |
|||
app2.UseRouting(); |
|||
app2.UseConfiguredEndpoints(); |
|||
} |
|||
); |
|||
app.UseOcelot().Wait(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using EShopOnAbp.Shared.Hosting.AspNetCore; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
|
|||
namespace EShopOnAbp.WebPublicGateway |
|||
{ |
|||
public class Program |
|||
{ |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
|
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
|
|||
try |
|||
{ |
|||
Log.Information($"Starting {assemblyName}."); |
|||
await CreateHostBuilder(args).Build().RunAsync(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
} |
|||
|
|||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Host.CreateDefaultBuilder(args) |
|||
.ConfigureAppConfiguration(build => |
|||
{ |
|||
build.AddJsonFile("appsettings.secrets.json", optional: true); |
|||
}) |
|||
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }) |
|||
.UseAutofac() |
|||
.UseSerilog(); |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
{ |
|||
"$schema": "http://json.schemastore.org/launchsettings.json", |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "https://localhost:44373", |
|||
"sslPort": 0 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"EShopOnAbp.PublicWebGateway": { |
|||
"commandName": "Project", |
|||
"dotnetRunMessages": "true", |
|||
"launchBrowser": true, |
|||
"applicationUrl": "https://localhost:44373", |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace EShopOnAbp.WebPublicGateway |
|||
{ |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddApplication<EShopOnAbpWebPublicGatewayModule>(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft": "Warning", |
|||
"Microsoft.Hosting.Lifetime": "Information" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
{ |
|||
"App": { |
|||
"SelfUrl": "https://localhost:44373", |
|||
"CorsOrigins": "https://localhost:44335" |
|||
}, |
|||
"AuthServer": { |
|||
"Authority": "https://localhost:44330", |
|||
"RequireHttpsMetadata": "true", |
|||
"SwaggerClientId": "WebPublicGateway_Swagger", |
|||
"SwaggerClientSecret": "1q2w3e*" |
|||
}, |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft": "Warning", |
|||
"Microsoft.Hosting.Lifetime": "Information" |
|||
} |
|||
}, |
|||
"AllowedHosts": "*", |
|||
"Routes": [ |
|||
{ |
|||
"DownstreamPathTemplate": "/api/account/{everything}", |
|||
"DownstreamScheme": "https", |
|||
"DownstreamHostAndPorts": [ |
|||
{ |
|||
"Host": "localhost", |
|||
"Port": 44351 |
|||
} |
|||
], |
|||
"UpstreamPathTemplate": "/api/account/{everything}", |
|||
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ] |
|||
}, |
|||
{ |
|||
"DownstreamPathTemplate": "/api/abp/{everything}", |
|||
"DownstreamScheme": "https", |
|||
"DownstreamHostAndPorts": [ |
|||
{ |
|||
"Host": "localhost", |
|||
"Port": 44353 |
|||
} |
|||
], |
|||
"UpstreamPathTemplate": "/api/abp/{everything}", |
|||
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ] |
|||
} |
|||
], |
|||
"GlobalConfiguration": { |
|||
"BaseUrl": "https://localhost:44373" |
|||
}, |
|||
"Redis": { |
|||
"Configuration": "localhost:6379" |
|||
}, |
|||
"ElasticSearch": { |
|||
"Url": "http://localhost:9200" |
|||
} |
|||
} |
|||
Loading…
Reference in new issue