From a6fb1cb9e9df2481edabf03a415195c7e636a719 Mon Sep 17 00:00:00 2001 From: bicijinlian Date: Sat, 8 May 2021 18:33:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/TestController.cs | 22 ++++++++ OcelotStudy.Getway/OcelotStudy.Getway.csproj | 18 +++++++ OcelotStudy.Getway/Program.cs | 37 +++++++++++++ .../Properties/launchSettings.json | 30 +++++++++++ OcelotStudy.Getway/Startup.cs | 39 ++++++++++++++ .../appsettings.Development.json | 9 ++++ OcelotStudy.Getway/appsettings.json | 11 ++++ OcelotStudy.Getway/ocelot.json | 32 ++++++++++++ OcelotStudy.Getway/wwwroot/Index.html | 18 +++++++ OcelotStudy.Getway/wwwroot/favicon.ico | Bin 0 -> 9662 bytes .../Controllers/ServiceAController.cs | 22 ++++++++ .../OcelotStudy.WebApiA.csproj | 8 +++ OcelotStudy.WebApiA/Program.cs | 27 ++++++++++ .../Properties/launchSettings.json | 30 +++++++++++ OcelotStudy.WebApiA/Startup.cs | 49 ++++++++++++++++++ .../appsettings.Development.json | 9 ++++ OcelotStudy.WebApiA/appsettings.json | 11 ++++ .../Controllers/ServiceBController.cs | 22 ++++++++ .../OcelotStudy.WebApiB.csproj | 8 +++ OcelotStudy.WebApiB/Program.cs | 27 ++++++++++ .../Properties/launchSettings.json | 30 +++++++++++ OcelotStudy.WebApiB/Startup.cs | 49 ++++++++++++++++++ .../appsettings.Development.json | 9 ++++ OcelotStudy.WebApiB/appsettings.json | 11 ++++ OcelotStudy.sln | 37 +++++++++++++ 25 files changed, 565 insertions(+) create mode 100644 OcelotStudy.Getway/Controllers/TestController.cs create mode 100644 OcelotStudy.Getway/OcelotStudy.Getway.csproj create mode 100644 OcelotStudy.Getway/Program.cs create mode 100644 OcelotStudy.Getway/Properties/launchSettings.json create mode 100644 OcelotStudy.Getway/Startup.cs create mode 100644 OcelotStudy.Getway/appsettings.Development.json create mode 100644 OcelotStudy.Getway/appsettings.json create mode 100644 OcelotStudy.Getway/ocelot.json create mode 100644 OcelotStudy.Getway/wwwroot/Index.html create mode 100644 OcelotStudy.Getway/wwwroot/favicon.ico create mode 100644 OcelotStudy.WebApiA/Controllers/ServiceAController.cs create mode 100644 OcelotStudy.WebApiA/OcelotStudy.WebApiA.csproj create mode 100644 OcelotStudy.WebApiA/Program.cs create mode 100644 OcelotStudy.WebApiA/Properties/launchSettings.json create mode 100644 OcelotStudy.WebApiA/Startup.cs create mode 100644 OcelotStudy.WebApiA/appsettings.Development.json create mode 100644 OcelotStudy.WebApiA/appsettings.json create mode 100644 OcelotStudy.WebApiB/Controllers/ServiceBController.cs create mode 100644 OcelotStudy.WebApiB/OcelotStudy.WebApiB.csproj create mode 100644 OcelotStudy.WebApiB/Program.cs create mode 100644 OcelotStudy.WebApiB/Properties/launchSettings.json create mode 100644 OcelotStudy.WebApiB/Startup.cs create mode 100644 OcelotStudy.WebApiB/appsettings.Development.json create mode 100644 OcelotStudy.WebApiB/appsettings.json create mode 100644 OcelotStudy.sln diff --git a/OcelotStudy.Getway/Controllers/TestController.cs b/OcelotStudy.Getway/Controllers/TestController.cs new file mode 100644 index 0000000..6252642 --- /dev/null +++ b/OcelotStudy.Getway/Controllers/TestController.cs @@ -0,0 +1,22 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace OcelotStudy.Getway.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class TestController : ControllerBase + { + public IActionResult Get() + { + var data = new { Name="Ocelot 娴嬭瘯Api"}; + + return Ok(data) ; + } + } +} diff --git a/OcelotStudy.Getway/OcelotStudy.Getway.csproj b/OcelotStudy.Getway/OcelotStudy.Getway.csproj new file mode 100644 index 0000000..5372733 --- /dev/null +++ b/OcelotStudy.Getway/OcelotStudy.Getway.csproj @@ -0,0 +1,18 @@ + + + + netcoreapp3.1 + + + + + + + + + Always + + + + + diff --git a/OcelotStudy.Getway/Program.cs b/OcelotStudy.Getway/Program.cs new file mode 100644 index 0000000..3452813 --- /dev/null +++ b/OcelotStudy.Getway/Program.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace OcelotStudy.Getway +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureAppConfiguration((hostingContext, config) => + { + //添加配置文件的使用 + config + .SetBasePath(hostingContext.HostingEnvironment.ContentRootPath) + .AddJsonFile("appsettings.json", true, true) + .AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true) + .AddJsonFile("ocelot.json") + .AddEnvironmentVariables(); + }) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } +} diff --git a/OcelotStudy.Getway/Properties/launchSettings.json b/OcelotStudy.Getway/Properties/launchSettings.json new file mode 100644 index 0000000..05cfc53 --- /dev/null +++ b/OcelotStudy.Getway/Properties/launchSettings.json @@ -0,0 +1,30 @@ +锘縶 + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:6353", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "OcelotStudy.Getway": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "Index.html", + "applicationUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/OcelotStudy.Getway/Startup.cs b/OcelotStudy.Getway/Startup.cs new file mode 100644 index 0000000..4a60701 --- /dev/null +++ b/OcelotStudy.Getway/Startup.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +using Ocelot.DependencyInjection; +using Ocelot.Middleware; + +namespace OcelotStudy.Getway +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + public void ConfigureServices(IServiceCollection services) + { + services.AddOcelot(); + } + + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + app.UseStaticFiles(); + app.UseOcelot(); + } + } +} diff --git a/OcelotStudy.Getway/appsettings.Development.json b/OcelotStudy.Getway/appsettings.Development.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/OcelotStudy.Getway/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/OcelotStudy.Getway/appsettings.json b/OcelotStudy.Getway/appsettings.json new file mode 100644 index 0000000..ce23979 --- /dev/null +++ b/OcelotStudy.Getway/appsettings.json @@ -0,0 +1,11 @@ +{ + "urls": "http://localhost:5000", + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/OcelotStudy.Getway/ocelot.json b/OcelotStudy.Getway/ocelot.json new file mode 100644 index 0000000..185a87b --- /dev/null +++ b/OcelotStudy.Getway/ocelot.json @@ -0,0 +1,32 @@ +{ + "Routes": [ + { + "DownstreamPathTemplate": "/api/ServiceA/ping", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "localhost", + "Port": 5101 + } + ], + "UpstreamPathTemplate": "/api/ServiceA", + "UpstreamHttpMethod": [ "Get" ] + }, + { + "DownstreamPathTemplate": "/api/ServiceB/ping", + "DownstreamHostAndPorts": [ + { + "Host": "localhost", + "Port": 5102 + } + ], + "DownstreamPort": 5102, + "UpstreamPathTemplate": "/api/ServiceB", + "UpstreamHttpMethod": [ "Get" ] + } + ], + "GlobalConfiguration": { + "RequestIdKey": "OcRequestId", + "AdministrationPath": "/administration" + } +} diff --git a/OcelotStudy.Getway/wwwroot/Index.html b/OcelotStudy.Getway/wwwroot/Index.html new file mode 100644 index 0000000..e8c7c79 --- /dev/null +++ b/OcelotStudy.Getway/wwwroot/Index.html @@ -0,0 +1,18 @@ +锘 + + + + 椤圭洰璇存槑 + + +

+ Ocelot 缃戝叧椤圭洰锛屾墍鏈夊姛鑳藉熀浜庢墜鍔ㄩ厤缃枃浠躲 +

+
+ 娴嬭瘯闇鍚屾椂鍚姩鍒涓や釜鏈嶅姟椤圭洰锛 + 涔嬪悗锛屾湰缃戝叧鍩哄湴鍧鍚庯紝鍔 + http://缃戝叧/api/ServiceA + http://缃戝叧/api/ServiceB +
+ + \ No newline at end of file diff --git a/OcelotStudy.Getway/wwwroot/favicon.ico b/OcelotStudy.Getway/wwwroot/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..cd294c17f47ebca50c7aa9cfb90c1889a2274d12 GIT binary patch literal 9662 zcmcgx2~bm6x~7pr%d)zyF3YmIEZeetj^o(2<1n=Cu1%vNvV?sR5ipVf0U;nDTL>W} zAtWIi*$5#(fUxg7gb-p_j0lJh(rWX3JRif@6h+Y#oj&isvAbvb)qB&+ycX)ue@}AH zIp2ToIp4or8=H6F|L9R0_}pt#`ENEhJ8f)i4uZf}HlZNc_twAtZ`8l~nNdZsy<3L2 zO_GP%#tN_5#)yJ!W5hwW*tofkWCz6v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GSpcKh+|Azkd9H?>t_@sz`qr+ z+kyPgq2F4&&0K9$F(i2(>TwRK8oUX008_*1|SQGSse&P`_FAh8jA#@fyk=ARxxQIK&(QG2C7) z9%ojyJSqzrn;+Qq6T`mspDP9>j_j6nTB`Pz5wG^J&<10$IvL6ziMP;)No$gEngQPJ zlXTBokGyqoKV!n`q2gV#zIg<*_c=8vS!G(Rqh=$frMGCDtCtu?$= za6fahu7`E+!@IvT4Kp$t_Wls_SB&Af1$dX$Zuqk0*zlKaJ0=$N|1W%r(AOU#WMlJp z{neICtPNP-fsd~-%$YVeUt#*}cltvco99^jJsX>W%x^b;13C+Rv-#W2HZ~OW^=1Tm z6Lk1+la0;h=WrVZ^Z*Fx_b?6e-a^(UGw2Ud)@Jk^+9+!irvLu;&Ucravff;58hE4M zd5-DLU)wzYFbi;gWAoKn!1)h4`9rMz_4ea$^sZCyS=+mJTlF`)&%Dv^ey892#@Yrm ztoMJr85RWkqfOsw%A4^~)>oO#sMxX~TM0fB)t?{q1{i I+HdrK18HQNOaK4? literal 0 HcmV?d00001 diff --git a/OcelotStudy.WebApiA/Controllers/ServiceAController.cs b/OcelotStudy.WebApiA/Controllers/ServiceAController.cs new file mode 100644 index 0000000..5fcb01d --- /dev/null +++ b/OcelotStudy.WebApiA/Controllers/ServiceAController.cs @@ -0,0 +1,22 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace OcelotStudy.WebApiA.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class ServiceAController : ControllerBase + { + public IActionResult Ping() + { + var data = new { Name="鏈嶅姟A",Describe="娴嬭瘯鏈嶅姟A" }; + + return Ok(data); + } + } +} diff --git a/OcelotStudy.WebApiA/OcelotStudy.WebApiA.csproj b/OcelotStudy.WebApiA/OcelotStudy.WebApiA.csproj new file mode 100644 index 0000000..adaae29 --- /dev/null +++ b/OcelotStudy.WebApiA/OcelotStudy.WebApiA.csproj @@ -0,0 +1,8 @@ +锘 + + + netcoreapp3.1 + + + + diff --git a/OcelotStudy.WebApiA/Program.cs b/OcelotStudy.WebApiA/Program.cs new file mode 100644 index 0000000..b2680fc --- /dev/null +++ b/OcelotStudy.WebApiA/Program.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace OcelotStudy.WebApiA +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } +} diff --git a/OcelotStudy.WebApiA/Properties/launchSettings.json b/OcelotStudy.WebApiA/Properties/launchSettings.json new file mode 100644 index 0000000..df04834 --- /dev/null +++ b/OcelotStudy.WebApiA/Properties/launchSettings.json @@ -0,0 +1,30 @@ +锘縶 + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:34710", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "OcelotStudy.WebApiA": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "api/ServiceA/ping", + "applicationUrl": "http://localhost:5101", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/OcelotStudy.WebApiA/Startup.cs b/OcelotStudy.WebApiA/Startup.cs new file mode 100644 index 0000000..cb08b9e --- /dev/null +++ b/OcelotStudy.WebApiA/Startup.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace OcelotStudy.WebApiA +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddControllers(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/OcelotStudy.WebApiA/appsettings.Development.json b/OcelotStudy.WebApiA/appsettings.Development.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/OcelotStudy.WebApiA/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/OcelotStudy.WebApiA/appsettings.json b/OcelotStudy.WebApiA/appsettings.json new file mode 100644 index 0000000..dc9ac33 --- /dev/null +++ b/OcelotStudy.WebApiA/appsettings.json @@ -0,0 +1,11 @@ +{ + "urls": "http://localhost:5101", + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/OcelotStudy.WebApiB/Controllers/ServiceBController.cs b/OcelotStudy.WebApiB/Controllers/ServiceBController.cs new file mode 100644 index 0000000..0094b6d --- /dev/null +++ b/OcelotStudy.WebApiB/Controllers/ServiceBController.cs @@ -0,0 +1,22 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace OcelotStudy.WebApiB.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class ServiceBController : ControllerBase + { + public IActionResult Ping() + { + var data = new { Name="鏈嶅姟B",Describe="娴嬭瘯鏈嶅姟B" }; + + return Ok(data); + } + } +} diff --git a/OcelotStudy.WebApiB/OcelotStudy.WebApiB.csproj b/OcelotStudy.WebApiB/OcelotStudy.WebApiB.csproj new file mode 100644 index 0000000..d12c450 --- /dev/null +++ b/OcelotStudy.WebApiB/OcelotStudy.WebApiB.csproj @@ -0,0 +1,8 @@ + + + + netcoreapp3.1 + + + + diff --git a/OcelotStudy.WebApiB/Program.cs b/OcelotStudy.WebApiB/Program.cs new file mode 100644 index 0000000..ea2630e --- /dev/null +++ b/OcelotStudy.WebApiB/Program.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace OcelotStudy.WebApiB +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } +} diff --git a/OcelotStudy.WebApiB/Properties/launchSettings.json b/OcelotStudy.WebApiB/Properties/launchSettings.json new file mode 100644 index 0000000..30f7e7a --- /dev/null +++ b/OcelotStudy.WebApiB/Properties/launchSettings.json @@ -0,0 +1,30 @@ +锘縶 + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:12569", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "OcelotStudy.WebApiB": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "api/ServiceB/ping", + "applicationUrl": "http://localhost:5102", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/OcelotStudy.WebApiB/Startup.cs b/OcelotStudy.WebApiB/Startup.cs new file mode 100644 index 0000000..a5f1ac9 --- /dev/null +++ b/OcelotStudy.WebApiB/Startup.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace OcelotStudy.WebApiB +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddControllers(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/OcelotStudy.WebApiB/appsettings.Development.json b/OcelotStudy.WebApiB/appsettings.Development.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/OcelotStudy.WebApiB/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/OcelotStudy.WebApiB/appsettings.json b/OcelotStudy.WebApiB/appsettings.json new file mode 100644 index 0000000..e0f3bad --- /dev/null +++ b/OcelotStudy.WebApiB/appsettings.json @@ -0,0 +1,11 @@ +{ + "urls": "http://localhost:5102", + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/OcelotStudy.sln b/OcelotStudy.sln new file mode 100644 index 0000000..12de4f0 --- /dev/null +++ b/OcelotStudy.sln @@ -0,0 +1,37 @@ +锘 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31205.134 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OcelotStudy.WebApiA", "OcelotStudy.WebApiA\OcelotStudy.WebApiA.csproj", "{EF25A97D-2330-463A-9AE7-8F02D41F8ABE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OcelotStudy.WebApiB", "OcelotStudy.WebApiB\OcelotStudy.WebApiB.csproj", "{B1E66C70-6D81-4998-A7D6-C2089773E2A3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OcelotStudy.Getway", "OcelotStudy.Getway\OcelotStudy.Getway.csproj", "{006D1F30-AE0D-454A-B402-1EB9AB35AF82}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EF25A97D-2330-463A-9AE7-8F02D41F8ABE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EF25A97D-2330-463A-9AE7-8F02D41F8ABE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EF25A97D-2330-463A-9AE7-8F02D41F8ABE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EF25A97D-2330-463A-9AE7-8F02D41F8ABE}.Release|Any CPU.Build.0 = Release|Any CPU + {B1E66C70-6D81-4998-A7D6-C2089773E2A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B1E66C70-6D81-4998-A7D6-C2089773E2A3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B1E66C70-6D81-4998-A7D6-C2089773E2A3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B1E66C70-6D81-4998-A7D6-C2089773E2A3}.Release|Any CPU.Build.0 = Release|Any CPU + {006D1F30-AE0D-454A-B402-1EB9AB35AF82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {006D1F30-AE0D-454A-B402-1EB9AB35AF82}.Debug|Any CPU.Build.0 = Debug|Any CPU + {006D1F30-AE0D-454A-B402-1EB9AB35AF82}.Release|Any CPU.ActiveCfg = Release|Any CPU + {006D1F30-AE0D-454A-B402-1EB9AB35AF82}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E511B0EB-F326-4865-B034-67F1F5C78631} + EndGlobalSection +EndGlobal