2.9 KiB
2.9 KiB
Configurable Route Table - Static Files Serving
Module
Gateway
Status
VERIFIED
Description
The Gateway supports a StaticFiles route type that serves directory contents mapped to a URL prefix. Configured via StellaOpsRoute with Type = StaticFiles, Path = URL prefix, TranslatesTo = physical directory path. Supports SPA fallback (serving index.html for extensionless paths) when the route's Headers["x-spa-fallback"] is set to "true". Files are served with correct MIME types via FileExtensionContentTypeProvider. Multiple StaticFiles routes can coexist with isolated path scopes.
Implementation Details
- Modules:
src/Router/__Libraries/StellaOps.Router.Gateway/,src/Router/StellaOps.Gateway.WebService/ - Key Classes:
StellaOpsRoute(src/Router/__Libraries/StellaOps.Router.Gateway/Configuration/StellaOpsRoute.cs) - Route model withStellaOpsRouteType.StaticFilesStellaOpsRouteResolver(src/Router/StellaOps.Gateway.WebService/Routing/StellaOpsRouteResolver.cs) - First-match-wins route resolution engineRouteDispatchMiddleware(src/Router/StellaOps.Gateway.WebService/Middleware/RouteDispatchMiddleware.cs) -HandleStaticFilesmethod usesPhysicalFileProviderandFileExtensionContentTypeProviderGatewayOptionsValidator(src/Router/StellaOps.Gateway.WebService/Configuration/GatewayOptionsValidator.cs) - Validates StaticFiles route has non-empty TranslatesTo directory path
- Tests:
RouteTableIntegrationTests(src/Router/__Tests/StellaOps.Gateway.WebService.Tests/Integration/RouteTableIntegrationTests.cs) - 8 StaticFiles integration testsGatewayOptionsValidatorTests(src/Router/__Tests/StellaOps.Gateway.WebService.Tests/Configuration/GatewayOptionsValidatorTests.cs) - StaticFiles validation tests
E2E Test Plan
- Serve a file from a mapped directory:
GET /app/index.htmlreturns HTML content with 200 andContent-Type: text/html - Serve a nested file:
GET /app/assets/style.cssreturns CSS content with 200 andContent-Type: text/css - Return 404 for missing file:
GET /app/missing.txtreturns 404 - Verify MIME types:
.html->text/html,.css->text/css,.js->application/javascript,.json->application/json - SPA fallback:
GET /app/some/route(extensionless) returnsindex.htmlwhenx-spa-fallback=true - Multiple mappings isolation:
/app/and/docs/serve from different directories without interference
Verification
- Run ID: run-001
- Date: 2026-02-12
- Method: Tier 0 source verification + Tier 1 build/code review (224/224 tests pass) + Tier 2a live HTTP API testing
- Build: PASS (0 errors, 0 warnings)
- Tests: PASS (224/224 Gateway tests pass)
- Tier 2a Evidence:
docs/qa/feature-checks/runs/gateway/configurable-route-table-static-files-serving/run-001/tier2-api-check.json - Verdict: PASS