Add in the middle ware and Fallbackcontroller.
This commit is contained in:
@@ -23,14 +23,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CarParkValidationAPI
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
public class Startup
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
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)
|
||||
@@ -38,8 +38,8 @@ namespace CarParkValidationAPI
|
||||
services.AddControllers();
|
||||
//** security
|
||||
var appSettingsSection = Configuration.GetSection("AppSettings");
|
||||
services.Configure<AppSettings>(appSettingsSection);
|
||||
|
||||
services.Configure<AppSettings>(appSettingsSection);
|
||||
|
||||
var appSettings = appSettingsSection.Get<AppSettings>();
|
||||
var key = Encoding.ASCII.GetBytes(appSettings.Secret);
|
||||
//***
|
||||
@@ -67,12 +67,12 @@ namespace CarParkValidationAPI
|
||||
|
||||
//**
|
||||
//publish need to take comment out
|
||||
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
// c.ResolveConflictingActions(api => api.First());
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "CarParkValidationAPI", Version = "v1" });
|
||||
});
|
||||
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
// c.ResolveConflictingActions(api => api.First());
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "CarParkValidationAPI", Version = "v1" });
|
||||
});
|
||||
/*
|
||||
services.AddSwaggerGen(option =>
|
||||
{
|
||||
@@ -94,48 +94,56 @@ namespace CarParkValidationAPI
|
||||
services.AddScoped(typeof(ConcessionValidationReportRepository));
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataContext context)
|
||||
{
|
||||
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
|
||||
}
|
||||
|
||||
app.UseSwagger();
|
||||
|
||||
app.UseSwaggerUI(c =>
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataContext context)
|
||||
{
|
||||
c.DocExpansion(Swashbuckle.AspNetCore.SwaggerUI.DocExpansion.None);
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "CarParkValidationAPI v1");
|
||||
});
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
// global cors policy
|
||||
app.UseCors(x => x
|
||||
.SetIsOriginAllowed(origin => true)
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.WithExposedHeaders("Content-Disposition")
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
|
||||
.AllowCredentials());
|
||||
}
|
||||
|
||||
// global error handler
|
||||
//app.UseMiddleware<ErrorHandlerMiddleware>();
|
||||
app.UseSwagger();
|
||||
|
||||
// custom jwt auth middleware
|
||||
app.UseMiddleware<JwtMiddleware>();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.DocExpansion(Swashbuckle.AspNetCore.SwaggerUI.DocExpansion.None);
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "CarParkValidationAPI v1");
|
||||
});
|
||||
|
||||
app.UseAuthorization();
|
||||
app.UseRouting();
|
||||
|
||||
// global cors policy
|
||||
app.UseCors(x => x
|
||||
.SetIsOriginAllowed(origin => true)
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.WithExposedHeaders("Content-Disposition")
|
||||
|
||||
.AllowCredentials());
|
||||
|
||||
// global error handler
|
||||
//app.UseMiddleware<ErrorHandlerMiddleware>();
|
||||
|
||||
// custom jwt auth middleware
|
||||
app.UseMiddleware<JwtMiddleware>();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
/* if add angular under wwwroot then two line below needed*/
|
||||
/***************************/
|
||||
// app.UseDefaultFiles(); //it will use index.html <------------------
|
||||
// app.UseStaticFiles(); //it for angular <-------------------------
|
||||
|
||||
/***************************/
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
// endpoints.MapFallbackToController("Index", "Fallback"); //<------------------ put angular in wwwroot.
|
||||
});
|
||||
}
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user