March Docs

Bastion

Bastion — a plug-style HTTP web framework for March.

Bastion wraps HttpServer with ergonomic higher-level abstractions: a declarative router, typed middleware pipeline, static file serving, and structured request/response helpers.

Usage:

fn main() do
  let router =
    Router.new()
    |> Router.get("/", home_handler)
    |> Router.get("/users/:id", user_handler)
    |> Router.post("/users", create_user_handler)

  Bastion.start(router, Bastion.default_opts(4000))
end

Types

typeOptsOpts = Opts(Int, Int, Int)#

Functions

fndefault_optsdefault_opts(port : Int) : Opts#

Returns a default Opts with the given port, 1000 max connections, and 60s idle timeout.

fnmainmain() : Unit#
fnopts_portopts_port(opts : Opts) : Int#

Returns the port from an Opts value.

fnportport(opts : Opts) : Int#

Alias for opts_port. Returns the port from an Opts value.

fnwith_idle_timeoutwith_idle_timeout(opts : Opts, secs : Int) : Opts#

Returns a new Opts with idle_timeout (in seconds) replaced.

fnwith_max_connectionswith_max_connections(opts : Opts, n : Int) : Opts#

Returns a new Opts with max_connections replaced.

fnwith_portwith_port(opts : Opts, port : Int) : Opts#

Returns a new Opts with the port replaced.