serve_dir

Function serve_dir 

Source
pub fn serve_dir(
    prefix: impl Into<String>,
    root: impl Into<PathBuf>,
) -> StaticFileConfig
Expand description

Create a static file serving route

This is the main function for adding static file serving to RustAPI.

§Arguments

  • prefix - URL path prefix (e.g., “/static”)
  • root - File system root directory

§Example

use rustapi_core::static_files::serve_dir;

// The handler can be used with a catch-all route
let config = serve_dir("/static", "./public");