diff options
| author | transtrike <transtrike@gmail.com> | 2020-12-14 23:29:14 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2020-12-14 23:29:14 +0200 |
| commit | dee2e37a4a8759108390c664e06bf147b8385cbf (patch) | |
| tree | bd65fe5649731a55aa6f1d8b48d53d89032fb8be /src/DevHive.Web/Startup.cs | |
| parent | 1ccdefdac025b1b986ad2bd0bc3eda7505d6e7c3 (diff) | |
| download | DevHive-dee2e37a4a8759108390c664e06bf147b8385cbf.tar DevHive-dee2e37a4a8759108390c664e06bf147b8385cbf.tar.gz DevHive-dee2e37a4a8759108390c664e06bf147b8385cbf.zip | |
Stabalized project for compilation. Next step after init architecture
Diffstat (limited to 'src/DevHive.Web/Startup.cs')
| -rw-r--r-- | src/DevHive.Web/Startup.cs | 99 |
1 files changed, 50 insertions, 49 deletions
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 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.AddControllers();
- services.AddSwaggerGen(c =>
- {
- c.SwaggerDoc("v1", new OpenApiInfo { Title = "DevHive.Web", Version = "v1" });
- });
- }
-
- // 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"));
- }
-
- app.UseHttpsRedirection();
-
- app.UseRouting();
-
- app.UseAuthorization();
-
- app.UseEndpoints(endpoints =>
- {
- endpoints.MapControllers();
- });
- }
- }
+ 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.
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddControllers();
+
+ services.DatabaseConfiguration(Configuration);
+ services.SwaggerConfiguration();
+ services.JWTConfiguration(Configuration);
+ //services.AutoMapperConfiguration();
+
+ services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
+ }
+
+ // 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.UseDatabaseConfiguration();
+
+ app.UseEndpoints(endpoints =>
+ {
+ endpoints.MapControllerRoute(
+ name: "default",
+ pattern: "api/{controller}/{action}"
+ );
+ });
+ }
+ }
}
|
