11
11
using Microsoft . AspNetCore . Hosting ;
12
12
using Microsoft . Extensions . Configuration ;
13
13
using Microsoft . Extensions . DependencyInjection ;
14
+ using Microsoft . Extensions . Hosting ;
15
+ using Microsoft . AspNetCore . Mvc . NewtonsoftJson ;
14
16
15
17
namespace Hexastore . Web
16
18
{
@@ -26,20 +28,19 @@ public Startup(IConfiguration configuration)
26
28
// This method gets called by the runtime. Use this method to add services to the container.
27
29
public void ConfigureServices ( IServiceCollection services )
28
30
{
29
- // services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
30
- services . AddCors ( options =>
31
- {
31
+ services . AddCors ( options => {
32
32
options . AddPolicy ( "AllowAnyOrigin" ,
33
33
builder => builder
34
34
. AllowAnyOrigin ( )
35
35
. AllowAnyMethod ( )
36
36
. WithExposedHeaders ( "content-disposition" )
37
37
. AllowAnyHeader ( )
38
- . AllowCredentials ( )
39
38
. SetPreflightMaxAge ( TimeSpan . FromSeconds ( 3600 ) ) ) ;
40
39
} ) ;
41
40
42
- services . AddMvc ( ) ;
41
+
42
+ services . AddControllers ( ) . AddNewtonsoftJson ( ) ;
43
+
43
44
services . AddSingleton < IGraphProvider , RocksGraphProvider > ( ) ;
44
45
services . AddSingleton < IReasoner , Reasoner > ( ) ;
45
46
services . AddSingleton < IStoreProcesor , StoreProcessor > ( ) ;
@@ -54,7 +55,7 @@ public void ConfigureServices(IServiceCollection services)
54
55
}
55
56
56
57
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
57
- public void Configure ( IApplicationBuilder app , IHostingEnvironment env )
58
+ public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
58
59
{
59
60
if ( File . Exists ( "/var/data/Hexastore.env" ) ) {
60
61
DotEnv . Config ( false , "/var/data/Hexastore.env" ) ;
@@ -68,7 +69,14 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
68
69
app . UseCors ( "AllowAnyOrigin" ) ;
69
70
70
71
app . UseMiddleware < PerfHeaderMiddleware > ( ) ;
71
- app . UseMvc ( ) ;
72
+
73
+ // app.UseHttpsRedirection();
74
+ // app.UseAuthorization();
75
+ app . UseRouting ( ) ;
76
+
77
+ app . UseEndpoints ( endpoints => {
78
+ endpoints . MapControllers ( ) ;
79
+ } ) ;
72
80
}
73
81
}
74
82
}
0 commit comments