54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
#region
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
#endregion
|
|
|
|
namespace website {
|
|
public class Startup {
|
|
public Startup(IConfiguration configuration) {
|
|
this.configuration = configuration;
|
|
}
|
|
|
|
public IConfiguration configuration { get; }
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
public void configureServices(IServiceCollection services) {
|
|
services.AddControllers();
|
|
services.AddCors();
|
|
services.AddSwaggerGen(c => {
|
|
c.SwaggerDoc("v1", new OpenApiInfo {Title = "website", Version = "v1"});
|
|
});
|
|
}
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
public void configure(IApplicationBuilder app, IWebHostEnvironment env) {
|
|
if (env.IsDevelopment()) {
|
|
app.UseDeveloperExceptionPage();
|
|
app.UseSwagger(c => c.RouteTemplate = "/api/{documentname}/swagger.json");
|
|
app.UseSwaggerUI(c => {
|
|
c.SwaggerEndpoint("/api/v1/swagger.json", "website v1");
|
|
c.RoutePrefix = "api/website";
|
|
});
|
|
}
|
|
|
|
app.UseCors(builder => {
|
|
builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
|
|
});
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseRouting();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
|
|
}
|
|
}
|
|
}
|