Module

Yoga.HTTP.API.Route.RouteHandler

Package
purescript-yoga-http-api
Repository
rowtype-yoga/purescript-yoga-http-api

#Handler Source

data Handler t0

A handler tied to a specific route type.

Usage: userHandler :: Handler UserRoute userHandler = mkHandler { path } -> ...

#RouteHandler Source

class RouteHandler :: Type -> Row Type -> Row Type -> Row Type -> Type -> Row Type -> Constraintclass RouteHandler (route :: Type) (pathParams :: Row Type) (queryParams :: Row Type) (reqHeaders :: Row Type) (body :: Type) (respVariant :: Row Type) | route -> pathParams queryParams reqHeaders body respVariant

Type class that computes the handler function type from a Route type.

Instances

#RouteCookies Source

class RouteCookies :: Type -> Row Type -> Constraintclass RouteCookies (route :: Type) (cookies :: Row Type) | route -> cookies

Compute the cookie row declared by a route request.

Instances

#mkHandler Source

mkHandler :: forall route pathParams queryParams reqHeaders reqCookies body respVariant. RouteHandler route pathParams queryParams reqHeaders body respVariant => RouteCookies route reqCookies => HandlerFnWithCookies pathParams queryParams reqHeaders reqCookies body respVariant -> Handler route

Create a handler from the route's complete typed request. The cookie row is inferred from the route, so cookie-aware routes need no alternate constructor.

#mkHandlerWithCookies Source

mkHandlerWithCookies :: forall route pathParams queryParams reqHeaders reqCookies body respVariant. RouteHandler route pathParams queryParams reqHeaders body respVariant => RouteCookies route reqCookies => HandlerFnWithCookies pathParams queryParams reqHeaders reqCookies body respVariant -> Handler route

Compatibility name for cookie-aware handlers. Prefer mkHandler.

#runHandler Source

runHandler :: forall route pathParams queryParams reqHeaders body respVariant. RouteHandler route pathParams queryParams reqHeaders body respVariant => RouteCookies route () => Handler route -> HandlerFn pathParams queryParams reqHeaders body respVariant

Run a handler for a route whose cookie row is empty. Cookie-bearing routes must use runHandlerWithCookies.

#runHandlerWithCookies Source

runHandlerWithCookies :: forall route pathParams queryParams reqHeaders reqCookies body respVariant. RouteHandler route pathParams queryParams reqHeaders body respVariant => RouteCookies route reqCookies => Handler route -> HandlerFnWithCookies pathParams queryParams reqHeaders reqCookies body respVariant

Run the canonical cookie-aware handler representation.

#APIHandlers Source

class APIHandlers :: RowList Type -> Row Type -> Constraintclass APIHandlers (rl :: RowList Type) (handlerRow :: Row Type) | rl -> handlerRow

Instances

#apiHandlers Source

apiHandlers :: forall @api apiRow rl handlerRow. ApiRecord api apiRow => RowToList apiRow rl => APIHandlers rl handlerRow => Record handlerRow -> Record handlerRow

#ApiRecord Source

class ApiRecord :: Type -> Row Type -> Constraintclass ApiRecord (api :: Type) (row :: Row Type) | api -> row

Instances