kex docs Standard Library

Web

A small, WEBrick-style web server API. Configuration is immutable: mounting a route returns an updated server, and start hands that configuration to the BEAM runtime.

module Web

record Request

Fields

method
String
path
String
queryString
String
headers
Map<String, String>
body
String

record Response

Fields

status
Integer optional
headers
Map<String, String> optional
body
String optional

Implements Http.

Defined in other modules

module Web.Response

text

text(body: String) -> Response

textWithStatus

textWithStatus(body: String, status: Integer) -> Response

html

html(body: String) -> Response

json

json(body: String) -> Response

redirect

redirect(location: String) -> Response

notFound constant

notFound : Response

type Handler

record Route

Fields

method
String
path
String
handler
Handler

record Server

Fields

routes
[Route] optional

Defined in other modules

type Web.Server

mount

mount(path: String, handler: Handler) -> Server

get

get(path: String, handler: Handler) -> Server

post

post(path: String, handler: Handler) -> Server

put

put(path: String, handler: Handler) -> Server

patch

patch(path: String, handler: Handler) -> Server

delete

delete(path: String, handler: Handler) -> Server

start

start : Result<Void, String>

module Web.Server

build

build(port: Integer) -> Server