Yoga.HTTP.API.Route.Handler
- Package
- purescript-yoga-http-api
- Repository
- rowtype-yoga/purescript-yoga-http-api
#HandlerFn Source
type HandlerFn :: Row Type -> Row Type -> Row Type -> Type -> Row Type -> Typetype HandlerFn pathParams queryParams reqHeaders body respVariant = { body :: body, headers :: Record reqHeaders, path :: Record pathParams, query :: Record queryParams } -> Aff (Variant respVariant)
Type-safe handler tied to a route's computed types.
Usage: myHandler :: Handler (id :: Int) (limit :: Maybe Int) (authorization :: BearerToken) User (ok :: ResponseData () (Array Post), notFound :: ResponseData () ErrorMessage) myHandler { path, query, headers, body } = do -- path :: { id :: Int } -- query :: { limit :: Maybe Int } -- headers :: { authorization :: BearerToken } -- body :: User pure $ respondNoHeaders (Proxy :: _ "ok") []
#DefaultRequestFields Source
class DefaultRequestFields :: Row Type -> Row Type -> Row Type -> Type -> Constraintclass DefaultRequestFields (partialRequest :: Row Type) (fullHeaders :: Row Type) (fullCookies :: Row Type) (fullEncoding :: Type) | partialRequest -> fullHeaders fullCookies fullEncoding
Compute defaults for missing request fields using RowList.
When a Request omits headers, defaults to ().
When a Request omits cookies, defaults to ().
When a Request omits body, defaults to NoBody.
Instances
(RowToList partialRequest rl, DefaultRequestFieldsRL rl partialRequest fullHeaders fullCookies fullEncoding) => DefaultRequestFields partialRequest fullHeaders fullCookies fullEncoding
#DefaultRequestFieldsRL Source
class DefaultRequestFieldsRL :: RowList Type -> Row Type -> Row Type -> Row Type -> Type -> Constraintclass DefaultRequestFieldsRL (rl :: RowList Type) (partialRequest :: Row Type) (fullHeaders :: Row Type) (fullCookies :: Row Type) (fullEncoding :: Type) | rl partialRequest -> fullHeaders fullCookies fullEncoding
RowList-based implementation
Instances
DefaultRequestFieldsRL Nil partialRequest () () NoBody(DefaultRequestFieldsRL tail partialRequest () cookies encoding) => DefaultRequestFieldsRL (Cons "headers" (Record headers) tail) partialRequest headers cookies encoding(DefaultRequestFieldsRL tail partialRequest headers () encoding) => DefaultRequestFieldsRL (Cons "cookies" (Record cookies) tail) partialRequest headers cookies encoding(DefaultRequestFieldsRL tail partialRequest headers cookies NoBody) => DefaultRequestFieldsRL (Cons "body" encoding tail) partialRequest headers cookies encoding(DefaultRequestFieldsRL tail partialRequest headers cookies encoding) => DefaultRequestFieldsRL (Cons otherLabel otherType tail) partialRequest headers cookies encoding
#SegmentPathParams Source
class SegmentPathParams :: forall k. k -> Row Type -> Constraintclass SegmentPathParams segments params | segments -> params
Extract the row of typed path parameters from a path segments type.
Instances
(CaptureParams path params) => SegmentPathParams (QueryParams path (Record q)) params(CaptureParams segs params) => SegmentPathParams segs params
#SegmentQueryParams Source
class SegmentQueryParams :: forall k. k -> Row Type -> Constraintclass SegmentQueryParams segments query | segments -> query
Extract the row of typed query parameters from a path segments type.
Instances
(RowToList params rl, SegmentQueryParamsRL rl query) => SegmentQueryParams (QueryParams path (Record params)) querySegmentQueryParams segs ()
#SegmentQueryParamsRL Source
class SegmentQueryParamsRL :: RowList Type -> Row Type -> Constraintclass SegmentQueryParamsRL (rl :: RowList Type) (query :: Row Type) | rl -> query
RowList-based processing of query param rows. Required ty → ty (plain), otherwise → Maybe ty
Instances
SegmentQueryParamsRL Nil ()(SegmentQueryParamsRL tail tailQuery, Cons name ty tailQuery query, Lacks name tailQuery) => SegmentQueryParamsRL (Cons name (Required ty) tail) query(SegmentQueryParamsRL tail tailQuery, Cons name (Maybe ty) tailQuery query, Lacks name tailQuery) => SegmentQueryParamsRL (Cons name ty tail) query
#EncodingBody Source
class EncodingBody (encoding :: Type) (body :: Type) | encoding -> bodyMap encoding phantom types to the runtime body type the handler receives.
Instances
EncodingBody (JSON a) aEncodingBody NoBody UnitEncodingBody (Record row) (Record row)
#CaptureParams Source
class CaptureParams :: forall k. k -> Row Type -> Constraintclass CaptureParams segs (params :: Row Type) | segs -> params
Walk the path segments and collect all Capture/Param entries into a row.
Instances
(CaptureParams left leftParams, CaptureParams right rightParams, Union leftParams rightParams params, Nub params params) => CaptureParams (PathCons left right) params(Cons name ty () params, Lacks name ()) => CaptureParams (Capture name ty) params(Cons name ty () params, Lacks name ()) => CaptureParams (Param name ty) params(CaptureParams segs params) => CaptureParams (Path segs) paramsCaptureParams s ()
#RequestHeaders Source
class RequestHeaders :: Type -> Row Type -> Constraintclass RequestHeaders (request :: Type) (headers :: Row Type) | request -> headers
Extract the headers row from a request record type.
The request is expected to have a headers field.
Instances
(Cons "headers" (Record headers) _rest requestRow) => RequestHeaders (Record requestRow) headers
#RequestCookies Source
class RequestCookies :: Type -> Row Type -> Constraintclass RequestCookies (request :: Type) (cookies :: Row Type) | request -> cookies
Extract the cookies row from a request record type.
The request is expected to have a cookies field.
Instances
(Cons "cookies" (Record cookies) _rest requestRow) => RequestCookies (Record requestRow) cookies
#RequestBody Source
class RequestBody (request :: Type) (encoding :: Type) | request -> encodingExtract the body encoding type from a request record type.
The request is expected to have a body field.
Instances
(Cons "body" encoding _rest requestRow) => RequestBody (Record requestRow) encoding
- Modules
- Yoga.
HTTP. API. Path - Yoga.
HTTP. API. Route - Yoga.
HTTP. API. Route. Auth - Yoga.
HTTP. API. Route. BearerToken - Yoga.
HTTP. API. Route. Encoding - Yoga.
HTTP. API. Route. Handler - Yoga.
HTTP. API. Route. HeaderError - Yoga.
HTTP. API. Route. HeaderValue - Yoga.
HTTP. API. Route. Method - Yoga.
HTTP. API. Route. OpenAPI - Yoga.
HTTP. API. Route. OpenAPIMetadata - Yoga.
HTTP. API. Route. RenderMethod - Yoga.
HTTP. API. Route. Response - Yoga.
HTTP. API. Route. Route - Yoga.
HTTP. API. Route. RouteHandler - Yoga.
HTTP. API. Route. StatusCode