12
12
using Microsoft . Extensions . Configuration ;
13
13
using Microsoft . Extensions . DependencyInjection ;
14
14
using Microsoft . IdentityModel . Tokens ;
15
+ using Microsoft . OpenApi . Models ;
15
16
using Swashbuckle . AspNetCore . Swagger ;
16
17
17
18
public class Startup
@@ -46,10 +47,10 @@ public void ConfigureServices(IServiceCollection services)
46
47
. AllowAnyHeader ( )
47
48
. AllowAnyMethod ( ) . AllowCredentials ( )
48
49
) ) ;
49
- services . AddMvc ( ) . SetCompatibilityVersion ( CompatibilityVersion . Version_2_1 ) ;
50
+ services . AddControllers ( ) ;
50
51
services . AddSwaggerGen ( c =>
51
52
{
52
- c . SwaggerDoc ( "v1" , new Info { Title = "APIJSON.NET" , Version = "v1" } ) ;
53
+ c . SwaggerDoc ( "v1" , new OpenApiInfo { Title = "APIJSON.NET" , Version = "v1" } ) ;
53
54
} ) ;
54
55
services . AddSingleton < DbContext > ( ) ;
55
56
services . AddSingleton < SelectTable > ( ) ;
@@ -61,17 +62,12 @@ public void ConfigureServices(IServiceCollection services)
61
62
}
62
63
63
64
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
64
- public void Configure ( IApplicationBuilder app , IHostingEnvironment env )
65
+ public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
65
66
{
66
67
67
68
app . UseAuthentication ( ) ;
68
69
69
- app . UseMvc ( routes =>
70
- {
71
- routes . MapRoute (
72
- name : "default" ,
73
- template : "{controller=Home}/{action=Index}/{id?}" ) ;
74
- } ) ;
70
+ app . UseRouting ( ) ;
75
71
app . UseStaticFiles ( ) ;
76
72
app . UseCors ( _defaultCorsPolicyName ) ;
77
73
app . UseSwagger ( ) ;
@@ -80,7 +76,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
80
76
c . SwaggerEndpoint ( "/swagger/v1/swagger.json" , "My API V1" ) ;
81
77
82
78
} ) ;
83
-
79
+ app . UseEndpoints ( endpoints =>
80
+ {
81
+ endpoints . MapControllers ( ) ;
82
+ } ) ;
84
83
app . UseJwtTokenMiddleware ( ) ;
85
84
DbInit . Initialize ( app ) ;
86
85
}
0 commit comments