fist
Types
A node in the router tree, representing a route segment.
pub type Node(req_body, output) {
Node(
handler: option.Option(
fn(request.Request(req_body), dict.Dict(String, String)) -> output,
),
static_children: dict.Dict(String, Node(req_body, output)),
dynamic_child: option.Option(
#(String, Node(req_body, output)),
),
)
}
Constructors
-
Node( handler: option.Option( fn(request.Request(req_body), dict.Dict(String, String)) -> output, ), static_children: dict.Dict(String, Node(req_body, output)), dynamic_child: option.Option(#(String, Node(req_body, output))), )
Values
pub fn delete(
router: Router(req_body, output),
path path: String,
to handler: fn(
request.Request(req_body),
dict.Dict(String, String),
) -> output,
) -> Router(req_body, output)
Adds a DELETE route to the router.
pub fn get(
router: Router(req_body, output),
path path: String,
to handler: fn(
request.Request(req_body),
dict.Dict(String, String),
) -> output,
) -> Router(req_body, output)
Adds a GET route to the router.
pub fn get_query(
req: request.Request(mist.Connection),
) -> dict.Dict(String, String)
pub fn handle(
router: Router(req_body, output),
request: request.Request(req_body),
not_found: fn() -> output,
) -> output
pub fn json(body: String) -> response.Response(String)
Creates a 200 OK response with the given string as body and application/json content type.
pub fn map(
router: Router(req_body, a),
with fun: fn(a) -> b,
) -> Router(req_body, b)
Maps the output of all handlers in the router.
pub fn ok(body: body) -> response.Response(body)
Creates a 200 OK response with the given body.
pub fn patch(
router: Router(req_body, output),
path path: String,
to handler: fn(
request.Request(req_body),
dict.Dict(String, String),
) -> output,
) -> Router(req_body, output)
Adds a PATCH route to the router.
pub fn post(
router: Router(req_body, output),
path path: String,
to handler: fn(
request.Request(req_body),
dict.Dict(String, String),
) -> output,
) -> Router(req_body, output)
Adds a POST route to the router.
pub fn put(
router: Router(req_body, output),
path path: String,
to handler: fn(
request.Request(req_body),
dict.Dict(String, String),
) -> output,
) -> Router(req_body, output)
Adds a PUT route to the router.
pub fn redirect(to: String) -> response.Response(String)
Creates a 302 Found redirect response.
pub fn render_mist(
res: response.Response(String),
) -> response.Response(mist.ResponseData)
Renders a Response(String) into a Response(mist.ResponseData) for use with Mist.
pub fn route(
router: Router(req_body, output),
method method: http.Method,
path path: String,
handler handler: fn(
request.Request(req_body),
dict.Dict(String, String),
) -> output,
) -> Router(req_body, output)
Inserts a route into the router.
pub fn start(
router: Router(
mist.Connection,
response.Response(mist.ResponseData),
),
port port: Int,
) -> Nil
pub fn text(body: String) -> response.Response(String)
Creates a 200 OK response with the given string as body and text/plain content type.