-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
83 lines (65 loc) · 2.54 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using Microsoft.AspNetCore.Mvc;
using System.Reflection;
internal class Program
{
private static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
#region Builder configurations
//Add filters
builder.Services.AddControllers(option =>
{
//option.Filters.Add(typeof(RequireJsonContentTypeAttribute));
option.Filters.Add(new ProducesAttribute("application/json"));
});
builder.Services.AddHealthChecks();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(setup =>
{
setup.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo
{
Title = "Scheduler Backend service for React-Scheduler",
Description = "Use this API to integrate it with React-Scheduler. Use this API to save data to 3rd party store",
Version = "v1",
Contact = new Microsoft.OpenApi.Models.OpenApiContact
{
Email = "[email protected]",
Name = "Shantanu Gupta",
Url = new Uri("https://linkedin.com/in/shantanufrom4387")
}
});
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
setup.IncludeXmlComments(xmlPath);
});
//builder.Services.AddCors(p => p.AddPolicy("corspolicy", build =>
//{
// build.WithOrigins("http://localhost:3000").AllowAnyMethod().AllowAnyHeader();
//}));
#endregion
var app = builder.Build();
#region App configuration
app.MapHealthChecks("/healthz");
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
//app.UseCors(p => p.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
}
else if(app.Environment.IsProduction())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseCors(p => p.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
//app.UseCors("corspolicy");
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
#endregion
app.Run();
}
}