forked from ReduxISU/Redux
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
67 lines (53 loc) · 2.04 KB
/
Program.cs
File metadata and controls
67 lines (53 loc) · 2.04 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System.Reflection;
using Microsoft.Extensions.FileProviders;
using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Configuration.GetSection("QuantumSolver").Get<QuantumSolverSettings>();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "Redux API",
Description = "An ASP.NET Core Web API for reducing, verifying, and solving NP-Complete problems",
// 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")
// }
});
options.CustomSchemaIds(type => type.FullName);
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
});
var app = builder.Build();
app.UseStaticFiles();
// Somewhat of a security concern. But since we are not doing POSTS im not concerned about it
app.Use((context, next) =>
{
context.Response.Headers["Access-Control-Allow-Origin"] = "*";
return next.Invoke();
});
// app.UseHttpsRedirection();
app.UseCors(x => x
.AllowAnyMethod()
.AllowAnyHeader()
.SetIsOriginAllowed(origin => true) // allow any origin
.AllowCredentials()); // allow credentials
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(c =>
c.InjectStylesheet("/assests/css/swagger.css")
);
app.MapControllers();
app.Run();