aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Startup.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Timeline/Startup.cs')
-rw-r--r--Timeline/Startup.cs29
1 files changed, 13 insertions, 16 deletions
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs
index b5a5106b..7552df2e 100644
--- a/Timeline/Startup.cs
+++ b/Timeline/Startup.cs
@@ -1,9 +1,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpOverrides;
-using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Timeline.Authenticate;
@@ -16,23 +14,23 @@ namespace Timeline
{
public class Startup
{
- public Startup(IConfiguration configuration, IHostingEnvironment environment)
+ public Startup(IConfiguration configuration, IWebHostEnvironment environment)
{
Environment = environment;
Configuration = configuration;
}
- public IHostingEnvironment Environment { get; }
+ public IWebHostEnvironment Environment { 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)
{
services.AddMvc()
- .ConfigureApiBehaviorOptions(options =>{
+ .ConfigureApiBehaviorOptions(options =>
+ {
options.InvalidModelStateResponseFactory = InvalidModelResponseFactory.Factory;
- })
- .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
+ });
services.Configure<JwtConfig>(Configuration.GetSection(nameof(JwtConfig)));
var jwtConfig = Configuration.GetSection(nameof(JwtConfig)).Get<JwtConfig>();
@@ -52,14 +50,7 @@ namespace Timeline
services.AddDbContext<DatabaseContext>(options =>
{
- options.UseMySql(databaseConfig.ConnectionString)
- .ConfigureWarnings(warnings =>
- {
- if (Environment.IsProduction())
- warnings.Log(RelationalEventId.QueryClientEvaluationWarning);
- else
- warnings.Throw(RelationalEventId.QueryClientEvaluationWarning);
- });
+ options.UseMySql(databaseConfig.ConnectionString);
});
services.AddHttpClient();
@@ -75,9 +66,15 @@ namespace Timeline
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
+ app.UseRouting();
+
app.UseAuthentication();
+ app.UseAuthorization();
- app.UseMvc();
+ app.UseEndpoints(endpoints =>
+ {
+ endpoints.MapControllers();
+ });
}
}
}