Payload.Server.Response
- Package
- purescript-payload
- Repository
- hoodunit/purescript-payload
This module contains various helpers for returning server responses.
#status Source
status :: forall a. HttpStatus -> a -> Response a
#updateStatus Source
updateStatus :: forall a. (HttpStatus -> HttpStatus) -> Response a -> Response a
#updateBody Source
updateBody :: forall a b. (a -> b) -> Response a -> Response b
#ToSpecResponse Source
class ToSpecResponse (docRoute :: Symbol) a b where
This 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 :: Proxy docRoute -> a -> Result (Response b)
Instances
(EncodeResponse a) => ToSpecResponse docRoute (Either Failure a) a
(EncodeResponse a) => ToSpecResponse docRoute (Either Failure (Response a)) a
(EncodeResponse err) => ToSpecResponse docRoute (Either (Response err) a) a
(EncodeResponse err) => ToSpecResponse docRoute (Either (Response err) (Response a)) a
(EncodeResponse a, EncodeResponse err) => ToSpecResponse docRoute (Either err a) a
(EncodeResponse a, EncodeResponse err) => ToSpecResponse docRoute (Either err (Response a)) a
(EncodeResponse a) => ToSpecResponse docRoute (Response a) a
(EncodeResponse a) => ToSpecResponse docRoute 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 where
Any types that can appear in a server response body and show up in the API spec under the "body" field must implement EncodeResponse. This is also a good place to add a Content-Type header for the encoded response.
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
Status code: 101
#processing Source
processing :: forall a. a -> Response a
Status code: 102
#nonAuthoritativeInformation Source
nonAuthoritativeInformation :: forall a. a -> Response a
Status code: 203
#resetContent Source
resetContent :: forall a. a -> Response a
Status code: 205
#partialContent Source
partialContent :: forall a. a -> Response a
Status code: 206
#multiStatus Source
multiStatus :: forall a. a -> Response a
Status code: 207
#alreadyReported Source
alreadyReported :: forall a. a -> Response a
Status code: 208
#multipleChoices Source
multipleChoices :: forall a. a -> Response a
Status code: 300
#movedPermanently Source
movedPermanently :: forall a. a -> Response a
Status code: 301
#notModified Source
notModified :: forall a. a -> Response a
Status code: 304
#temporaryRedirect Source
temporaryRedirect :: forall a. a -> Response a
Status code: 307
#permanentRedirect Source
permanentRedirect :: forall a. a -> Response a
Status code: 308
#badRequest Source
badRequest :: forall a. a -> Response a
Status code: 400
#unauthorized Source
unauthorized :: forall a. a -> Response a
Status code: 401
#paymentRequired Source
paymentRequired :: forall a. a -> Response a
Status code: 402
#methodNotAllowed Source
methodNotAllowed :: forall a. a -> Response a
Status code: 405
#notAcceptable Source
notAcceptable :: forall a. a -> Response a
Status code: 406
#proxyAuthenticationRequired Source
proxyAuthenticationRequired :: forall a. a -> Response a
Status code: 407
#requestTimeout Source
requestTimeout :: forall a. a -> Response a
Status code: 408
#lengthRequired Source
lengthRequired :: forall a. a -> Response a
Status code: 411
#preconditionFailed Source
preconditionFailed :: forall a. a -> Response a
Status code: 412
#payloadTooLarge Source
payloadTooLarge :: forall a. a -> Response a
Status code: 413
#uriTooLong Source
uriTooLong :: forall a. a -> Response a
Status code: 414
#unsupportedMediaType Source
unsupportedMediaType :: forall a. a -> Response a
Status code: 415
#rangeNotSatisfiable Source
rangeNotSatisfiable :: forall a. a -> Response a
Status code: 416
#expectationFailed Source
expectationFailed :: forall a. a -> Response a
Status code: 417
#misdirectedRequest Source
misdirectedRequest :: forall a. a -> Response a
Status code: 421
#unprocessableEntity Source
unprocessableEntity :: forall a. a -> Response a
Status code: 422
#failedDependency Source
failedDependency :: forall a. a -> Response a
Status code: 424
#upgradeRequired Source
upgradeRequired :: forall a. a -> Response a
Status code: 426
#preconditionRequired Source
preconditionRequired :: forall a. a -> Response a
Status code: 428
#tooManyRequests Source
tooManyRequests :: forall a. a -> Response a
Status code: 429
#requestHeaderFieldsTooLarge Source
requestHeaderFieldsTooLarge :: forall a. a -> Response a
Status code: 431
#internalError Source
internalError :: forall a. a -> Response a
Status code: 500
#notImplemented Source
notImplemented :: forall a. a -> Response a
Status code: 501
#badGateway Source
badGateway :: forall a. a -> Response a
Status code: 502
#gatewayTimeout Source
gatewayTimeout :: forall a. a -> Response a
Status code: 504
#httpVersionNotSupported Source
httpVersionNotSupported :: forall a. a -> Response a
Status code: 505
#variantAlsoNegotiates Source
variantAlsoNegotiates :: forall a. a -> Response a
Status code: 506
#insufficientStorage Source
insufficientStorage :: forall a. a -> Response a
Status code: 507
#loopDetected Source
loopDetected :: forall a. a -> Response a
Status code: 508
#notExtended Source
notExtended :: forall a. a -> Response a
Status code: 510
#networkAuthenticationRequired Source
networkAuthenticationRequired :: forall a. a -> Response a
Status code: 511
- Modules
- Payload.
Client - Payload.
Client. ClientApi - Payload.
Client. DecodeResponse - Payload.
Client. EncodeBody - Payload.
Client. EncodeParam - Payload.
Client. Internal. EncodeUri - Payload.
Client. Internal. Query - Payload.
Client. Internal. Url - Payload.
Client. Options - Payload.
Client. QueryParams - Payload.
Client. Queryable - Payload.
Client. Response - Payload.
ContentType - Payload.
Debug - Payload.
Headers - Payload.
Internal. QueryParsing - Payload.
Internal. Route - Payload.
Internal. UrlParsing - Payload.
Internal. Utils - Payload.
ResponseTypes - Payload.
Server - Payload.
Server. Cookies - Payload.
Server. DecodeBody - Payload.
Server. Guards - Payload.
Server. Handleable - Payload.
Server. Handlers - Payload.
Server. Internal. GuardParsing - Payload.
Server. Internal. MimeTypes - Payload.
Server. Internal. OmitEmpty - Payload.
Server. Internal. Query - Payload.
Server. Internal. Querystring - Payload.
Server. Internal. Request - Payload.
Server. Internal. ServerResponse - Payload.
Server. Internal. Trie - Payload.
Server. Internal. Url - Payload.
Server. Internal. UrlString - Payload.
Server. Params - Payload.
Server. Path - Payload.
Server. QueryParams - Payload.
Server. Response - Payload.
Server. Routable - Payload.
Server. Status - Payload.
Spec - Payload.
TypeErrors