-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
49 lines (35 loc) · 1.15 KB
/
Program.cs
File metadata and controls
49 lines (35 loc) · 1.15 KB
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
using api.peter.biz.Models;
using api.peter.biz.Services;
using Microsoft.AspNetCore.HttpOverrides;
var builder = WebApplication.CreateBuilder(args);
// Configure logging
builder.Logging.ClearProviders()
.AddConsole();
// Configure options
builder.Services.Configure<OAuthCredentials>(builder.Configuration.GetSection("OAuthCredentials"));
// Set up services
builder.Services.AddSingleton<TwitchService>();
builder.Services.AddHttpClient("TwitchOAuth", client =>
{
client.BaseAddress = new Uri("https://id.twitch.tv/");
});
builder.Services.AddMemoryCache();
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Forward headers for hosting behind reverse proxy on Apache2
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.MapGet("/ping", () => "pong");
app.Run();