1616using ServiceStack . Api . Swagger ;
1717using ServiceStack . Metadata ;
1818using ServiceStack . Web ;
19+ using ServiceStack . IO ;
20+ using ServiceStack . Aws . S3 ;
21+ using Amazon ;
22+ using Amazon . S3 ;
1923
2024namespace ServiceStack . Core . SelfHost
2125{
@@ -30,13 +34,16 @@ public void ConfigureServices(IServiceCollection services)
3034 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
3135 public void Configure ( IApplicationBuilder app , IHostingEnvironment env )
3236 {
33- app . UseDeveloperExceptionPage ( ) ;
37+ app . Use ( async ( context , next ) => {
38+ Console . WriteLine ( context . Request . Path . Value ) ;
39+ await next ( ) ;
40+ } ) ;
3441
3542 app . UseServiceStack ( new AppHost ( ) ) ;
3643
3744 app . Run ( async ( context ) =>
3845 {
39- await context . Response . WriteAsync ( "Hello World !" ) ;
46+ await context . Response . WriteAsync ( "Unhandled Request !" ) ;
4047 } ) ;
4148 }
4249 }
@@ -116,8 +123,23 @@ public AppHost()
116123
117124 public override void Configure ( Container container )
118125 {
126+ var s3Client = new AmazonS3Client (
127+ Environment . GetEnvironmentVariable ( "S3_ACCESS_KEY" ) ,
128+ Environment . GetEnvironmentVariable ( "S3_SECRET_KEY" ) ,
129+ RegionEndpoint . USEast1 ) ;
130+
131+ VirtualFiles = new S3VirtualFiles ( s3Client , "s3-postgresql" ) ;
132+
133+ Plugins . Add ( new TemplatePagesFeature ( ) ) ;
119134 Plugins . Add ( new SwaggerFeature ( ) ) ;
120135 }
136+ public override List < IVirtualPathProvider > GetVirtualFileSources ( )
137+ {
138+ var fileSources = base . GetVirtualFileSources ( ) ;
139+ fileSources . Add ( VirtualFiles ) ;
140+ return fileSources ;
141+ }
142+
121143 }
122144
123145}
0 commit comments