Skip to main content

static_handler

Function static_handler 

Source
pub async fn static_handler(
    root: &Path,
    uri_path: &str,
    headers: &HeaderMap,
) -> Response<Body>
Expand description

静态文件处理器(对齐 PHP think-worker Http::sendFile 完整流程)

将 URI 路径映射到文件系统路径,调用 serve_file

§参数

  • root — 静态文件根目录
  • uri_path — 请求 URI 路径(如 /static/style.css
  • headers — 请求头

§返回

  • 200/206/304 — 文件响应
  • 404 — 文件不存在或路径不安全