cowboy/cowboy
This is a simple wrapper over the erlang cowboy server. It is originall from gleam-lang/cowboy but has been modified to work with espresso.
original source: https://github.com/gleam-lang/cowboy/blob/83e2f20170e4a73e5499238149313f8329a2f41a/src/gleam/http/cowboy.gleam
Types
An incoming request that will be handled by the dispatch in gleam_cowboy_native.erl
pub external type CowboyRequest
The returned result of cowboy_router:compile
pub external type CowboyRouter
A Route can either be a service (a function that handles a request and response) or a router which is expanded into a list of services.
pub type Route(req, assigns, res) {
ServiceRoute(Service(req, assigns, res))
RouterRoute(Routes(req, assigns, res))
StaticRoute(String, Static)
WebsocketRoute(Websocket)
}
Constructors
-
ServiceRoute(Service(req, assigns, res))
-
RouterRoute(Routes(req, assigns, res))
-
StaticRoute(String, Static)
-
WebsocketRoute(Websocket)
Functions
pub fn router(routes: List(#(String, Route(a, b, c)))) -> CowboyRouter
Takes a list of route structures and compiles them into a cowboy router.