espresso
This is the base module for starting the http server. It also does things like retrieve the system port and halts but the main thing is the start function.
Functions
pub fn get_port() -> Int
Returns the port to listen on by reading the “PORT” environtment variable.
Defaults to 3000.
pub fn start(r: Router(a, b, c)) -> Nil
Starts the server with a router and returns the pid of the process.
Example
import espresso
import espresso/request.{Request}
import espresso/response.{send}
import espresso/router.{get}
pub fn main() {
let router =
router.new()
|> get("/", fn(_req: Request(BitString)) { send(202, "Main Route") })
espresso.start(router)
}