This module exports Nodetrout's public API.

#serve Source

serve :: forall layout handlers m content. Monad m => MonadEffect m => ResponseWritable content => Router layout (Record handlers) m (Tuple MediaType content) => Proxy layout -> Record handlers -> (m ~> Aff) -> (Error -> Effect Unit) -> Request -> Response -> Effect Unit

Creates a node-http-compatible request handler of type Request -> Response -> Effect Unit which executes the specified routing logic.

#serve' Source

serve' :: forall layout handlers content. ResponseWritable content => Router layout (Record handlers) Aff (Tuple MediaType content) => Proxy layout -> Record handlers -> (Error -> Effect Unit) -> Request -> Response -> Effect Unit

A version of serve that can be used where handlers run in ExceptT HTTPError Aff, i.e. the inner monad is already Aff.

Re-exports from Nodetrout.Internal.Error

#HTTPError Source

type HTTPError = { details :: Maybe String, overview :: String, priority :: Int, statusCode :: Int }

The type of an HTTP error, part of the handler type ExceptT HTTPError m a

#error505 Source

error505 :: HTTPError

A HTTP Version not supported error

#error504 Source

error504 :: HTTPError

A Gateway Time-out error

#error503 Source

error503 :: HTTPError

A Service Unavailable error

#error502 Source

error502 :: HTTPError

A Bad Gateway error

#error501 Source

error501 :: HTTPError

A Not Implemented error

#error500 Source

error500 :: HTTPError

A Internal Server Error error

#error422 Source

error422 :: HTTPError

A Unprocessable Entity error

#error418 Source

error418 :: HTTPError

A I'm a teapot error

#error417 Source

error417 :: HTTPError

A Expectation Failed error

#error416 Source

error416 :: HTTPError

A Request range not satisfiable error

#error415 Source

error415 :: HTTPError

A Unsupported Media Type error

#error414 Source

error414 :: HTTPError

A Request-URI Too Large error

#error413 Source

error413 :: HTTPError

A Request Entity Too Large error

#error412 Source

error412 :: HTTPError

A Precondition Failed error

#error411 Source

error411 :: HTTPError

A Length Required error

#error410 Source

error410 :: HTTPError

A Gone error

#error409 Source

error409 :: HTTPError

A Conflict error

#error407 Source

error407 :: HTTPError

A Proxy Authentication Required error

#error406 Source

error406 :: HTTPError

A Not Acceptable error

#error405 Source

error405 :: HTTPError

A Method Not Allowed error

#error404 Source

error404 :: HTTPError

A Not Found error

#error403 Source

error403 :: HTTPError

A Forbidden error

#error402 Source

error402 :: HTTPError

A Payment Required error

#error401 Source

error401 :: HTTPError

A Unauthorized error

#error400 Source

error400 :: HTTPError

A Bad Request error

#error307 Source

error307 :: HTTPError

A Temporary Redirect error

#error305 Source

error305 :: HTTPError

A Use Proxy error

#error304 Source

error304 :: HTTPError

A Not Modified error

#error303 Source

error303 :: HTTPError

A See Other error

#error302 Source

error302 :: HTTPError

A Found error

#error301 Source

error301 :: HTTPError

A Moved Permanently error

#error300 Source

error300 :: HTTPError

A Multiple Choices error