Website Summary Files Commits Branches @commit @diff @stats
path: root / src / DevHive.Web / Startup.cs
diff options
context:
space:
mode:
Commitdee2e37a4a8759108390c664e06bf147b8385cbf (patch)
Author
 transtrike <transtrike@gmail.com>
2020-12-14 23:29:14 +0200
Committer
 transtrike <transtrike@gmail.com>
2020-12-14 23:29:14 +0200
Filesbd65fe5649731a55aa6f1d8b48d53d89032fb8be /src/DevHive.Web/Startup.cs
DevHive-dee2e37a4a8759108390c664e06bf147b8385cbf.tar
DevHive-dee2e37a4a8759108390c664e06bf147b8385cbf.tar.gz
DevHive-dee2e37a4a8759108390c664e06bf147b8385cbf.zip
Parent1ccdefdac025b1b986ad2bd0bc3eda7505d6e7c3 (diff)
Stabalized project for compilation. Next step after init architecture
1 files changed, 44 insertions, 43 deletions
-rw-r--r--src/DevHive.Web/Startup.cs87
diff --git a/src/DevHive.Web/Startup.cs b/src/DevHive.Web/Startup.cs
index 303c080..62d9d2c 100644
--- a/src/DevHive.Web/Startup.cs
+++ b/src/DevHive.Web/Startup.cs
@@ -1,59 +1,60 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.HttpsPolicy;
-using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
-using Microsoft.Extensions.Logging;
-using Microsoft.OpenApi.Models;
+using DevHive.Web.Configurations.Extensions;
+using AutoMapper;
namespace DevHive.Web
{
- public class Startup
- {
- public Startup(IConfiguration configuration)
- {
- Configuration = configuration;
- }
+ public class Startup
+ {
+ 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)
- {
+ // This method gets called by the runtime. Use this method to add services to the container.
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddControllers();
- services.AddControllers();
- services.AddSwaggerGen(c =>
- {
- c.SwaggerDoc("v1", new OpenApiInfo { Title = "DevHive.Web", Version = "v1" });
- });
- }
+ services.DatabaseConfiguration(Configuration);
+ services.SwaggerConfiguration();
+ services.JWTConfiguration(Configuration);
+ //services.AutoMapperConfiguration();
- // 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();
- app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "DevHive.Web v1"));
- }
+ services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
+ }
- app.UseHttpsRedirection();
+ // 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.UseExceptionHandler("/api/HttpError");
+ app.UseSwaggerConfiguration();
+ }
+ else
+ {
+ app.UseExceptionHandler("/api/HttpError");
+ app.UseHsts();
+ }
- app.UseRouting();
-
- app.UseAuthorization();
-
- app.UseEndpoints(endpoints =>
- {
- endpoints.MapControllers();
- });
- }
- }
+ app.UseDatabaseConfiguration();
+
+ app.UseEndpoints(endpoints =>
+ {
+ endpoints.MapControllerRoute(
+ name: "default",
+ pattern: "api/{controller}/{action}"
+ );
+ });
+ }
+ }
}