2020-09-09 00:52:14 +08:00
|
|
|
|
using System.Net.Http;
|
2019-12-04 16:46:08 +08:00
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
|
2020-05-29 00:33:49 +08:00
|
|
|
|
namespace AntDesign.Docs.WasmHost
|
2019-12-04 16:46:08 +08:00
|
|
|
|
{
|
|
|
|
|
public class Startup
|
|
|
|
|
{
|
|
|
|
|
public Startup(IConfiguration configuration)
|
|
|
|
|
{
|
|
|
|
|
Configuration = configuration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
|
|
|
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
2020-09-09 00:52:14 +08:00
|
|
|
|
services.AddRazorPages();
|
|
|
|
|
services.AddTransient(sp => new HttpClient()
|
|
|
|
|
{
|
|
|
|
|
DefaultRequestHeaders =
|
|
|
|
|
{
|
|
|
|
|
// Use to call the github API on server side
|
|
|
|
|
{"User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36 Edg/81.0.416.68"}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
services.AddAntDesignDocs();
|
2019-12-04 16:46:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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();
|
2020-03-28 00:02:11 +08:00
|
|
|
|
app.UseWebAssemblyDebugging();
|
2019-12-04 16:46:08 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
app.UseExceptionHandler("/Error");
|
|
|
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
|
|
|
app.UseHsts();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.UseHttpsRedirection();
|
2020-03-28 00:02:11 +08:00
|
|
|
|
app.UseBlazorFrameworkFiles();
|
2019-12-04 16:46:08 +08:00
|
|
|
|
app.UseStaticFiles();
|
|
|
|
|
|
|
|
|
|
app.UseRouting();
|
|
|
|
|
|
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
|
|
{
|
2020-09-09 00:52:14 +08:00
|
|
|
|
endpoints.MapFallbackToPage("/_Host");
|
2019-12-04 16:46:08 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-09 00:52:14 +08:00
|
|
|
|
}
|