spaceship_helm/static

Values

pub fn directory(
  dir: String,
) -> fn(
  types.Context,
  fn(types.Context) -> response.Response(BitArray),
) -> response.Response(BitArray)

Create a static file serving middleware.

Serves files from the specified directory relative to the current working directory. If a file is found, it returns the file content with the appropriate Content-Type header. If not found, passes to the next handler.

Usage

let app = lustre.fetch("/", handler)
|> lustre.use(static.directory("public"))
pub fn directory_with_cache(
  dir: String,
  max_age: Int,
) -> fn(
  types.Context,
  fn(types.Context) -> response.Response(BitArray),
) -> response.Response(BitArray)

Create a static file serving middleware with custom cache duration.

Usage

let app = lustre.fetch("/", handler)
|> lustre.use(static.directory_with_cache("public", 86400))
Search Document