forked from Damenus/webmail
-
Notifications
You must be signed in to change notification settings - Fork 1
/
StartupTest.cs
97 lines (77 loc) · 2.99 KB
/
StartupTest.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using WebMail.Server;
using WebMail.Server.Extensions;
using Swashbuckle.AspNetCore.Swagger;
using System.Threading.Tasks;
using System.Net;
using WebMail.Server.SignalR;
using Microsoft.Extensions.Hosting;
namespace WebMail
{
public class Startup2
{
// Order or run
//1) Constructor
//2) Configure services
//3) Configure
private IWebHostEnvironment _hostingEnv;
public Startup2(IConfiguration configuration, IWebHostEnvironment env)
{
Configuration = configuration;
_hostingEnv = env;
Helpers.SetupSerilog();
// var builder = new ConfigurationBuilder()
// .SetBasePath(env.ContentRootPath)
// .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
// .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
// .AddEnvironmentVariables();
// if (env.IsDevelopment())
// {
// // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
// builder.AddUserSecrets<Startup>();
// }
// Configuration = builder.Build();
}
public static IConfiguration Configuration { get; set; }
// 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 http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
if (_hostingEnv.IsDevelopment())
{
services.AddSslCertificate(_hostingEnv);
}
services.AddOptions();
services.AddResponseCompression(options =>
{
options.MimeTypes = Helpers.DefaultMimeTypes;
});
services.AddCustomDbContext();
services.AddCustomIdentity();
services.AddCustomOpenIddict();
services.AddMemoryCache();
services.RegisterCustomServices();
services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN");
services.AddSignalR();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "WebMail", Version = "v1" });
});
}
public void Configure(IApplicationBuilder app)
{
app.AddDevMiddlewares();
if (_hostingEnv.IsProduction())
{
app.UseResponseCompression();
}
app.SetupMigrations();
app.UseXsrf();
app.UseStaticFiles();
app.UseAuthentication();
}
}
}