@@ -17,11 +17,18 @@ namespace Documentation.Builder.Http;
17
17
18
18
public class StaticWebHost
19
19
{
20
+ private readonly string _contentSource ;
20
21
private readonly WebApplication _webApplication ;
21
22
22
- public StaticWebHost ( int port )
23
+ public StaticWebHost ( int port , string contentSource )
23
24
{
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
+ } ) ;
25
32
DocumentationTooling . CreateServiceCollection ( builder . Services , LogLevel . Warning ) ;
26
33
27
34
_ = builder . Logging
@@ -49,14 +56,14 @@ private void SetUpRoutes()
49
56
_ = _webApplication . MapGet ( "{**slug}" , ServeDocumentationFile ) ;
50
57
}
51
58
52
- private static async Task < IResult > ServeDocumentationFile ( string slug , Cancel _ )
59
+ private async Task < IResult > ServeDocumentationFile ( string slug , Cancel _ )
53
60
{
54
61
// from the injected top level navigation which expects us to run on elastic.co
55
62
if ( slug . StartsWith ( "static-res/" ) )
56
63
return Results . NotFound ( ) ;
57
64
58
65
await Task . CompletedTask ;
59
- var path = Path . Combine ( Paths . WorkingDirectoryRoot . FullName , ".artifacts" , "assembly" ) ;
66
+ var path = Path . Combine ( Paths . WorkingDirectoryRoot . FullName , ".artifacts" , "assembly" , _contentSource ) ;
60
67
var localPath = Path . Combine ( path , slug . Replace ( '/' , Path . DirectorySeparatorChar ) ) ;
61
68
var fileInfo = new FileInfo ( localPath ) ;
62
69
var directoryInfo = new DirectoryInfo ( localPath ) ;
0 commit comments