@@ -37,17 +37,7 @@ public void ConfigureServices(IServiceCollection services)
37
37
{
38
38
services . AddOptions ( ) ;
39
39
services . AddDbContext < FoodDbContext > ( opt => opt . UseInMemoryDatabase ( "FoodDatabase" ) ) ;
40
- services . AddCors ( options =>
41
- {
42
- options . AddPolicy ( "AllowAllOrigins" ,
43
- builder =>
44
- {
45
- builder
46
- . AllowAnyOrigin ( )
47
- . AllowAnyHeader ( )
48
- . AllowAnyMethod ( ) ;
49
- } ) ;
50
- } ) ;
40
+ services . AddCustomCors ( "AllowAllOrigins" ) ;
51
41
52
42
services . AddSingleton < ISeedDataService , SeedDataService > ( ) ;
53
43
services . AddScoped < IFoodRepository , FoodSqlRepository > ( ) ;
@@ -59,30 +49,13 @@ public void ConfigureServices(IServiceCollection services)
59
49
var factory = x . GetRequiredService < IUrlHelperFactory > ( ) ;
60
50
return factory . GetUrlHelper ( actionContext ) ;
61
51
} ) ;
62
-
63
52
64
53
services . AddControllers ( )
65
54
. AddNewtonsoftJson ( options =>
66
55
options . SerializerSettings . ContractResolver = new CamelCasePropertyNamesContractResolver ( ) )
67
56
. SetCompatibilityVersion ( CompatibilityVersion . Version_3_0 ) ;
68
57
69
- services . AddApiVersioning (
70
- config =>
71
- {
72
- config . ReportApiVersions = true ;
73
- config . AssumeDefaultVersionWhenUnspecified = true ;
74
- config . DefaultApiVersion = new ApiVersion ( 1 , 0 ) ;
75
- config . ApiVersionReader = new HeaderApiVersionReader ( "api-version" ) ;
76
- } ) ;
77
- services . AddVersionedApiExplorer (
78
- options =>
79
- {
80
- options . GroupNameFormat = "'v'VVV" ;
81
-
82
- // note: this option is only necessary when versioning by url segment. the SubstitutionFormat
83
- // can also be used to control the format of the API version in route templates
84
- options . SubstituteApiVersionInUrl = true ;
85
- } ) ;
58
+ services . AddVersioning ( ) ;
86
59
services . AddTransient < IConfigureOptions < SwaggerGenOptions > , ConfigureSwaggerOptions > ( ) ;
87
60
services . AddSwaggerGen ( ) ;
88
61
0 commit comments