-
Notifications
You must be signed in to change notification settings - Fork 5
/
Program.cs
50 lines (38 loc) · 1.48 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using BuildingBlocks.Observability;
using BuildingBlocks.Observability.Middlewares;
using Microservices.WeatherService.GrpcServices;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Serilog;
var webApplicationBuilder = WebApplication.CreateBuilder(args);
var environment = webApplicationBuilder.Environment;
var configuration = webApplicationBuilder.Configuration;
webApplicationBuilder.Configuration
.SetBasePath(environment.ContentRootPath)
.AddJsonFile("appsettings.json", false, true)
.AddEnvironmentVariables()
.AddCommandLine(args);
webApplicationBuilder
.AddObservability()
.AddGrpcServices();
webApplicationBuilder.WebHost
.CaptureStartupErrors(true)
.UseKestrel(options =>
{
options.AddServerHeader = false;
// We have to separate into different ports because we don't use TLS
options.ListenAnyIP(6001, listeningOptions =>
{
listeningOptions.Protocols = HttpProtocols.Http1;
});
options.ListenAnyIP(16001, listeningOptions =>
{
listeningOptions.Protocols = HttpProtocols.Http2;
});
});
using var app = webApplicationBuilder.Build();
app.UseSerilogRequestLogging();
app
.UseTraceIdResponseHeader()
.MapGrpcServices();
app.MapGet("/", () => "WeatherService");
await app.RunAsync();