|
1 |
| -using System.IO; |
2 |
| - |
| 1 | +using Microsoft.AspNetCore.Builder; |
3 | 2 | using Microsoft.AspNetCore.Hosting;
|
4 | 3 | using Microsoft.Extensions.Configuration;
|
5 |
| - |
6 |
| -using Ocelot.DependencyInjection; |
7 |
| -using Ocelot.Middleware; |
| 4 | +using Microsoft.Extensions.Hosting; |
| 5 | +using Microsoft.Extensions.Logging; |
| 6 | +using System.IO; |
| 7 | + |
| 8 | +namespace Ocelot.Samples.OcelotBasic.ApiGateway; |
8 | 9 |
|
9 |
| -namespace OcelotBasic |
| 10 | +public class Program |
10 | 11 | {
|
11 |
| - public class Program |
| 12 | + public static void Main(string[] args) |
12 | 13 | {
|
13 |
| - public static void Main(string[] args) |
14 |
| - { |
15 |
| - new WebHostBuilder() |
16 |
| - .UseKestrel() |
17 |
| - .UseContentRoot(Directory.GetCurrentDirectory()) |
18 |
| - .ConfigureAppConfiguration((hostingContext, config) => |
19 |
| - { |
20 |
| - config |
21 |
| - .SetBasePath(hostingContext.HostingEnvironment.ContentRootPath) |
22 |
| - .AddJsonFile("appsettings.json", true, true) |
23 |
| - .AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true) |
24 |
| - .AddJsonFile("ocelot.json") |
25 |
| - .AddEnvironmentVariables(); |
26 |
| - }) |
27 |
| - .ConfigureServices(s => |
28 |
| - { |
29 |
| - s.AddOcelot(); |
30 |
| - }) |
31 |
| - .ConfigureLogging((hostingContext, logging) => |
32 |
| - { |
33 |
| - //add your logging |
34 |
| - }) |
35 |
| - .UseIISIntegration() |
36 |
| - .Configure(app => |
37 |
| - { |
38 |
| - app.UseOcelot().Wait(); |
39 |
| - }) |
40 |
| - .Build() |
41 |
| - .Run(); |
42 |
| - } |
| 14 | + new WebHostBuilder() |
| 15 | + .UseKestrel() |
| 16 | + .UseContentRoot(Directory.GetCurrentDirectory()) |
| 17 | + .ConfigureAppConfiguration((hostingContext, config) => |
| 18 | + { |
| 19 | + config |
| 20 | + .SetBasePath(hostingContext.HostingEnvironment.ContentRootPath) |
| 21 | + .AddJsonFile("appsettings.json", true, true) |
| 22 | + .AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true) |
| 23 | + .AddJsonFile("ocelot.json") |
| 24 | + .AddEnvironmentVariables(); |
| 25 | + }) |
| 26 | + .ConfigureLogging((hostingContext, logging) => |
| 27 | + { |
| 28 | + if (hostingContext.HostingEnvironment.IsDevelopment()) |
| 29 | + { |
| 30 | + logging.ClearProviders(); |
| 31 | + logging.AddConsole(); |
| 32 | + } |
| 33 | + //add your logging |
| 34 | + }) |
| 35 | + .UseIISIntegration() |
| 36 | + .UseStartup<Startup>() |
| 37 | + .Build() |
| 38 | + .Run(); |
43 | 39 | }
|
44 | 40 | }
|
0 commit comments