-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
65 lines (51 loc) · 1.85 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using Microsoft.OpenApi.Models;
using BadiService2.BadiMain;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var logger = LoggerFactory.Create(config =>
{
config.AddConsole();
}).CreateLogger("Program");
// builder.Services.AddSwaggerGen(options =>
// {
// options.SwaggerDoc("v1", new OpenApiInfo
// {
// Version = "v1",
// Title = "ToDo API",
// Description = "An ASP.NET Core Web API for managing ToDo items",
// TermsOfService = new Uri("https://example.com/terms"),
// Contact = new OpenApiContact
// {
// Name = "Example Contact",
// Url = new Uri("https://example.com/contact")
// },
// License = new OpenApiLicense
// {
// Name = "Example License",
// Url = new Uri("https://example.com/license")
// }
// });
// });
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
// app.UseHttpsRedirection();
BadiDate Run(HttpRequest request, int gYear = 0, int gMonth = 0, int gDay = 0, int fragment = 1)
{
logger.LogInformation($"{request.Scheme}://{request.Host}{request.PathBase}{request.Path}{request.QueryString}");
var gDate = gYear == 0 || gMonth == 0 || gDay == 0 ? DateTime.Today : new DateTime(gYear, gMonth, gDay);
var bDate = new BadiCalc().GetBadiDate(gDate, (RelationToSunset)fragment);
return bDate;
}
app.MapGet("/Today/{gYear?}/{gMonth?}/{gDay?}/{fragment?}", Run);
app.MapGet("/{gYear?}/{gMonth?}/{gDay?}/{fragment?}", Run);
// ports, see https://gist.github.com/davidfowl/ff1addd02d239d2d26f4648a06158727
// var port = Environment.GetEnvironmentVariable("PORT") ?? "8009";
app.Run();