@@ -17,11 +17,18 @@ namespace Documentation.Builder.Http;
1717
1818public class StaticWebHost
1919{
20+ private readonly string _contentSource ;
2021 private readonly WebApplication _webApplication ;
2122
22- public StaticWebHost ( int port )
23+ public StaticWebHost ( int port , string contentSource )
2324 {
24- var builder = WebApplication . CreateSlimBuilder ( ) ;
25+ _contentSource = contentSource ;
26+ var contentRoot = Path . Combine ( Paths . WorkingDirectoryRoot . FullName , ".artifacts" , "assembly" , _contentSource ) ;
27+
28+ var builder = WebApplication . CreateBuilder ( new WebApplicationOptions
29+ {
30+ ContentRootPath = contentRoot
31+ } ) ;
2532 DocumentationTooling . CreateServiceCollection ( builder . Services , LogLevel . Warning ) ;
2633
2734 _ = builder . Logging
@@ -49,14 +56,14 @@ private void SetUpRoutes()
4956 _ = _webApplication . MapGet ( "{**slug}" , ServeDocumentationFile ) ;
5057 }
5158
52- private static async Task < IResult > ServeDocumentationFile ( string slug , Cancel _ )
59+ private async Task < IResult > ServeDocumentationFile ( string slug , Cancel _ )
5360 {
5461 // from the injected top level navigation which expects us to run on elastic.co
5562 if ( slug . StartsWith ( "static-res/" ) )
5663 return Results . NotFound ( ) ;
5764
5865 await Task . CompletedTask ;
59- var path = Path . Combine ( Paths . WorkingDirectoryRoot . FullName , ".artifacts" , "assembly" ) ;
66+ var path = Path . Combine ( Paths . WorkingDirectoryRoot . FullName , ".artifacts" , "assembly" , _contentSource ) ;
6067 var localPath = Path . Combine ( path , slug . Replace ( '/' , Path . DirectorySeparatorChar ) ) ;
6168 var fileInfo = new FileInfo ( localPath ) ;
6269 var directoryInfo = new DirectoryInfo ( localPath ) ;
0 commit comments