Skip to main content

Module serve

Module serve 

Source
Expand description

Static-file actix handler for dev servers.

Serves files from a single output directory with:

  • basePath segment-aware stripping (so /webui-evil/x does not match /webui/),
  • traversal-safe path resolution,
  • <base href>-aware redirects (/foo → /foo/ for directory URLs),
  • automatic livereload script injection into HTML responses,
  • caller-controlled 404 strategy (plain text, custom file, etc.).

webui-cli does NOT use this handler — its serve command renders requests on the fly via the WebUI handler. webui-press uses it to serve the prebuilt out_dir.

Structs§

StaticServeConfig
Configuration for serve_static_file. Cheap to clone — paths are shared across requests.

Enums§

NotFoundStrategy
What to serve when a requested file isn’t found.

Functions§

serve_file_response
Build a 200 response for a successfully-read file, injecting the livereload script into HTML payloads. Public so callers with custom routing can serve files using the same headers/injection policy.
serve_static_file
Serve req from cfg, returning the appropriate HttpResponse.