File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ using System . Diagnostics . CodeAnalysis ;
2+ using Microsoft . AspNetCore . Builder ;
3+ using Microsoft . Extensions . FileProviders ;
4+
5+ namespace Initium . Extensions ;
6+
7+ [ SuppressMessage ( "ReSharper" , "UnusedMethodReturnValue.Global" ) ]
8+ public static class StaticFrontendExtensions
9+ {
10+ public static IApplicationBuilder MapStaticFrontend ( this IApplicationBuilder app , string clientPath )
11+ {
12+ app . UseDefaultFiles ( new DefaultFilesOptions
13+ {
14+ FileProvider = new PhysicalFileProvider ( clientPath ) ,
15+ RequestPath = "" ,
16+ DefaultFileNames = new List < string > { "index.html" }
17+ } ) ;
18+
19+ app . UseStaticFiles ( new StaticFileOptions
20+ {
21+ FileProvider = new PhysicalFileProvider ( clientPath ) ,
22+ RequestPath = ""
23+ } ) ;
24+
25+ // TODO: A quoi sert MapFallbackToFile?
26+ // app.MapFallbackToFile("index.html", Path.Combine(clientPath, "index.html"));
27+
28+ return app ;
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments