Payload.Response
- Package
- purescript-payload
- Repository
- hoodunit/purescript-payload
This module contains various helpers for returning server responses.
#Response Source
newtype Response rThe type of a server response, before encoding the body. Responses with modified statuses or headers can be created by returning this type (directly or via helper functions).
Constructors
Response { body :: r, headers :: Headers, status :: HttpStatus }
Instances
Newtype (Response a) _(Eq a) => Eq (Response a)(Show a) => Show (Response a)(EncodeResponse a) => ToSpecResponse route (Either Failure (Response a)) a(EncodeResponse err) => ToSpecResponse route (Either (Response err) a) a(EncodeResponse err) => ToSpecResponse route (Either (Response err) (Response a)) a(EncodeResponse a, EncodeResponse err) => ToSpecResponse route (Either err (Response a)) a(EncodeResponse a) => ToSpecResponse route (Response a) a
#Json Source
newtype Json aA JSON response body
Constructors
Json a
Instances
(WriteForeign r) => EncodeResponse (Json r)
#Failure Source
data FailureAll server error responses ultimately resolve into this type
Constructors
Instances
Show Failure(EncodeResponse a) => ToSpecResponse route (Either Failure a) a(EncodeResponse a) => ToSpecResponse route (Either Failure (Response a)) a
#RawResponse Source
type RawResponse = Response ResponseBodyAll server responses ultimately resolve into this type.
#ResponseBody Source
#UnsafeStream Source
data UnsafeStream#status Source
status :: forall a. HttpStatus -> a -> Response a#updateStatus Source
updateStatus :: forall a. (HttpStatus -> HttpStatus) -> Response a -> Response a#updateBody Source
updateBody :: forall b a. (a -> b) -> Response a -> Response b#ToSpecResponse Source
class ToSpecResponse (route :: Symbol) a b whereThis type class is for converting types which are compatible with the spec into the spec type. If the spec says one type is returned from an endpoint, a handler can either return that type directly or return another type from which that type can be produced (e.g. a full response with different headers or a different status code).
Members
toSpecResponse :: SProxy route -> a -> Result (Response b)
Instances
(EncodeResponse a) => ToSpecResponse route (Either Failure a) a(EncodeResponse a) => ToSpecResponse route (Either Failure (Response a)) a(EncodeResponse err) => ToSpecResponse route (Either (Response err) a) a(EncodeResponse err) => ToSpecResponse route (Either (Response err) (Response a)) a(EncodeResponse a, EncodeResponse err) => ToSpecResponse route (Either err a) a(EncodeResponse a, EncodeResponse err) => ToSpecResponse route (Either err (Response a)) a(EncodeResponse a) => ToSpecResponse route (Response a) a(EncodeResponse a) => ToSpecResponse route a a(Fail (Above (Text "Could not match or convert handler response type to spec response type.") (Above (Text "") (Above (Beside (Text " Route: ") (Text docRoute)) (Above (Beside (Text "Handler response: ") (Quote a)) (Above (Beside (Text " Spec response: ") (Quote b)) (Above (Text "") (Above (Text "Specifically, no type class instance was found for") (Above (Text "") (Above (Text "ToSpecResponse docRoute") (Above (Beside (Text " ") (Quote a)) (Above (Beside (Text " ") (Quote b)) (Text ""))))))))))))) => ToSpecResponse docRoute a b
#EncodeResponse Source
class EncodeResponse r whereTypes that can be encoded as response bodies and appear directly in API spec definitions.
Members
encodeResponse :: Response r -> Result RawResponse
Instances
EncodeResponse ResponseBody(WriteForeign (Record r)) => EncodeResponse (Record r)(WriteForeign (Array r)) => EncodeResponse (Array r)(WriteForeign r) => EncodeResponse (Json r)EncodeResponse String(TypeEquals (Stream r) (Stream (read :: Read | r'))) => EncodeResponse (Stream r)(EncodeResponse a) => EncodeResponse (Maybe a)EncodeResponse Empty
#switchingProtocols Source
switchingProtocols :: forall a. a -> Response a#processing Source
processing :: forall a. a -> Response a#nonAuthoritativeInformation Source
nonAuthoritativeInformation :: forall a. a -> Response a#resetContent Source
resetContent :: forall a. a -> Response a#partialContent Source
partialContent :: forall a. a -> Response a#multiStatus Source
multiStatus :: forall a. a -> Response a#alreadyReported Source
alreadyReported :: forall a. a -> Response a#multipleChoices Source
multipleChoices :: forall a. a -> Response a#movedPermanently Source
movedPermanently :: forall a. a -> Response a#notModified Source
notModified :: forall a. a -> Response a#temporaryRedirect Source
temporaryRedirect :: forall a. a -> Response a#permanentRedirect Source
permanentRedirect :: forall a. a -> Response a#badRequest Source
badRequest :: forall a. a -> Response a#unauthorized Source
unauthorized :: forall a. a -> Response a#paymentRequired Source
paymentRequired :: forall a. a -> Response a#methodNotAllowed Source
methodNotAllowed :: forall a. a -> Response a#notAcceptable Source
notAcceptable :: forall a. a -> Response a#proxyAuthenticationRequired Source
proxyAuthenticationRequired :: forall a. a -> Response a#requestTimeout Source
requestTimeout :: forall a. a -> Response a#lengthRequired Source
lengthRequired :: forall a. a -> Response a#preconditionFailed Source
preconditionFailed :: forall a. a -> Response a#payloadTooLarge Source
payloadTooLarge :: forall a. a -> Response a#uriTooLong Source
uriTooLong :: forall a. a -> Response a#unsupportedMediaType Source
unsupportedMediaType :: forall a. a -> Response a#rangeNotSatisfiable Source
rangeNotSatisfiable :: forall a. a -> Response a#expectationFailed Source
expectationFailed :: forall a. a -> Response a#misdirectedRequest Source
misdirectedRequest :: forall a. a -> Response a#unprocessableEntity Source
unprocessableEntity :: forall a. a -> Response a#failedDependency Source
failedDependency :: forall a. a -> Response a#upgradeRequired Source
upgradeRequired :: forall a. a -> Response a#preconditionRequired Source
preconditionRequired :: forall a. a -> Response a#tooManyRequests Source
tooManyRequests :: forall a. a -> Response a#requestHeaderFieldsTooLarge Source
requestHeaderFieldsTooLarge :: forall a. a -> Response a#internalError Source
internalError :: forall a. a -> Response a#notImplemented Source
notImplemented :: forall a. a -> Response a#badGateway Source
badGateway :: forall a. a -> Response a#gatewayTimeout Source
gatewayTimeout :: forall a. a -> Response a#httpVersionNotSupported Source
httpVersionNotSupported :: forall a. a -> Response a#variantAlsoNegotiates Source
variantAlsoNegotiates :: forall a. a -> Response a#insufficientStorage Source
insufficientStorage :: forall a. a -> Response a#loopDetected Source
loopDetected :: forall a. a -> Response a#notExtended Source
notExtended :: forall a. a -> Response a#networkAuthenticationRequired Source
networkAuthenticationRequired :: forall a. a -> Response a- Modules
- Payload.
Client. Client - Payload.
Client. FromResponse - Payload.
ContentType - Payload.
Cookies - Payload.
FromData - Payload.
Guards - Payload.
Handleable - Payload.
Handlers - Payload.
Headers - Payload.
Internal. GuardParsing - Payload.
Internal. MimeTypes - Payload.
Internal. Query - Payload.
Internal. QueryParsing - Payload.
Internal. Querystring. Qs - Payload.
Internal. Request - Payload.
Internal. Route - Payload.
Internal. ServerResponse - Payload.
Internal. Trie - Payload.
Internal. TypeErrors - Payload.
Internal. Url - Payload.
Internal. UrlParsing - Payload.
Internal. UrlString - Payload.
Internal. Utils - Payload.
Params - Payload.
Path - Payload.
QueryParams - Payload.
Response - Payload.
Routable - Payload.
Server - Payload.
Spec - Payload.
Status