Module

Yoga.HTTP.API.Route.Response

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

#Response Source

data Response :: Row Type -> Type -> Typedata Response headers body

Response data combining headers and body This is a data type (not type alias) to work with type class instances

Constructors

Instances

#ResponseData Source

type ResponseData :: Row Type -> Type -> Typetype ResponseData headers body = Response headers body

Deprecated alias for backwards compatibility

#ResponseHeaders Source

type ResponseHeaders :: Row Type -> Typetype ResponseHeaders headers = Response headers Unit

#ResponseBody Source

type ResponseBody body = Response () body

#EmptyResponse Source

#ToResponse Source

class ToResponse :: Type -> Row Type -> Type -> Constraintclass ToResponse (recordType :: Type) (headers :: Row Type) (body :: Type) | recordType -> headers body

Convert user-friendly record syntax to Response type.

Supports: Response headers body → Response headers body (identity) { body :: User } → Response () User { headers :: { "Location" :: String }, body :: User } → Response ("Location" :: String) User

Instances

#ToResponseRL Source

class ToResponseRL :: RowList Type -> Row Type -> Type -> Constraintclass ToResponseRL (rl :: RowList Type) (headers :: Row Type) (body :: Type) | rl -> headers body

RowList-based helper to distinguish records with/without headers. Instance heads are distinguishable by the RowList structure.

Instances

#respond Source

respond :: forall label headers body r1 r2. IsSymbol label => Cons label (Response headers body) r1 r2 => Proxy label -> Response headers body -> Variant r2

Construct a variant response with full control over headers and body

Example: respond (Proxy :: _ "created") (Response { headers: { "Location": "/users/123" }, body: user })

#respondWith Source

respondWith :: forall label headers body r1 r2. IsSymbol label => Cons label (Response headers body) r1 r2 => Proxy label -> Record headers -> body -> Variant r2

Construct a variant response with separate headers and body arguments

Example: respondWith (Proxy :: _ "created") { "Location": "/users/123" } user

#respondNoHeaders Source

respondNoHeaders :: forall @label body r1 r2. IsSymbol label => Cons label (Response () body) r1 r2 => body -> Variant r2

Construct a variant response with no custom headers (most common case)

Example: respondNoHeaders (Proxy :: _ "ok") user respondNoHeaders (Proxy :: _ "notFound") { error: "Not found" }

#respondStatus Source

respondStatus :: forall @code label body r1 r2. StatusCodeToLabel code label => IsSymbol label => Cons label (Response () body) r1 r2 => body -> Variant r2

Construct a variant response using numeric status code

Example: respondStatus @200 user respondStatus @404 { error: "Not found" }

#respondStatusWith Source

respondStatusWith :: forall @code label headers body r1 r2. StatusCodeToLabel code label => IsSymbol label => Cons label (Response headers body) r1 r2 => Record headers -> body -> Variant r2

Construct a variant response with headers using numeric status code

Example: respondStatusWith @201 { "Location": "/users/123" } user

#respondNoBody Source

respondNoBody :: forall label headers r1 r2. IsSymbol label => Cons label (Response headers Unit) r1 r2 => Proxy label -> Record headers -> Variant r2

Construct a variant response with headers but no body

Example: respondNoBody (Proxy :: _ "noContent") { "X-Resource-Id": "123" }

#respondNothing Source

respondNothing :: forall @label r1 r2. IsSymbol label => Cons label (Response () Unit) r1 r2 => Variant r2

Construct a variant response with neither headers nor body

Example: respondNothing (Proxy :: _ "noContent") respondNothing (Proxy :: _ "notModified")

#respondNoContent Source

respondNoContent :: forall r1 r2. Cons "noContent" (Response () Unit) r1 r2 => Variant r2

Construct a 204 No Content response (no headers, no body)

Example: respondNoContent

#respondNotModified Source

respondNotModified :: forall r1 r2. Cons "notModified" (Response () Unit) r1 r2 => Variant r2

Construct a 304 Not Modified response (no headers, no body)

Example: respondNotModified

#continue Source

continue :: forall body r1. body -> Variant (continue :: Response () body | r1)

#continueWith Source

continueWith :: forall headers body r1. Record headers -> body -> Variant (continue :: Response headers body | r1)

#switchingProtocols Source

switchingProtocols :: forall body r1. body -> Variant (switchingProtocols :: Response () body | r1)

#switchingProtocolsWith Source

switchingProtocolsWith :: forall headers body r1. Record headers -> body -> Variant (switchingProtocols :: Response headers body | r1)

#processing Source

processing :: forall body r1. body -> Variant (processing :: Response () body | r1)

#processingWith Source

processingWith :: forall headers body r1. Record headers -> body -> Variant (processing :: Response headers body | r1)

#earlyHints Source

earlyHints :: forall body r1. body -> Variant (earlyHints :: Response () body | r1)

#earlyHintsWith Source

earlyHintsWith :: forall headers body r1. Record headers -> body -> Variant (earlyHints :: Response headers body | r1)

#ok Source

ok :: forall body r1. body -> Variant (ok :: Response () body | r1)

#okWith Source

okWith :: forall headers body r1. Record headers -> body -> Variant (ok :: Response headers body | r1)

#created Source

created :: forall body r1. body -> Variant (created :: Response () body | r1)

#createdWith Source

createdWith :: forall headers body r1. Record headers -> body -> Variant (created :: Response headers body | r1)

#accepted Source

accepted :: forall body r1. body -> Variant (accepted :: Response () body | r1)

#acceptedWith Source

acceptedWith :: forall headers body r1. Record headers -> body -> Variant (accepted :: Response headers body | r1)

#nonAuthoritativeInformation Source

nonAuthoritativeInformation :: forall body r1. body -> Variant (nonAuthoritativeInformation :: Response () body | r1)

#nonAuthoritativeInformationWith Source

nonAuthoritativeInformationWith :: forall headers body r1. Record headers -> body -> Variant (nonAuthoritativeInformation :: Response headers body | r1)

#noContent Source

noContent :: forall body r1. body -> Variant (noContent :: Response () body | r1)

#noContentWith Source

noContentWith :: forall headers body r1. Record headers -> body -> Variant (noContent :: Response headers body | r1)

#resetContent Source

resetContent :: forall body r1. body -> Variant (resetContent :: Response () body | r1)

#resetContentWith Source

resetContentWith :: forall headers body r1. Record headers -> body -> Variant (resetContent :: Response headers body | r1)

#partialContent Source

partialContent :: forall body r1. body -> Variant (partialContent :: Response () body | r1)

#partialContentWith Source

partialContentWith :: forall headers body r1. Record headers -> body -> Variant (partialContent :: Response headers body | r1)

#multiStatus Source

multiStatus :: forall body r1. body -> Variant (multiStatus :: Response () body | r1)

#multiStatusWith Source

multiStatusWith :: forall headers body r1. Record headers -> body -> Variant (multiStatus :: Response headers body | r1)

#alreadyReported Source

alreadyReported :: forall body r1. body -> Variant (alreadyReported :: Response () body | r1)

#alreadyReportedWith Source

alreadyReportedWith :: forall headers body r1. Record headers -> body -> Variant (alreadyReported :: Response headers body | r1)

#imUsed Source

imUsed :: forall body r1. body -> Variant (imUsed :: Response () body | r1)

#imUsedWith Source

imUsedWith :: forall headers body r1. Record headers -> body -> Variant (imUsed :: Response headers body | r1)

#multipleChoices Source

multipleChoices :: forall body r1. body -> Variant (multipleChoices :: Response () body | r1)

#multipleChoicesWith Source

multipleChoicesWith :: forall headers body r1. Record headers -> body -> Variant (multipleChoices :: Response headers body | r1)

#movedPermanently Source

movedPermanently :: forall body r1. body -> Variant (movedPermanently :: Response () body | r1)

#movedPermanentlyWith Source

movedPermanentlyWith :: forall headers body r1. Record headers -> body -> Variant (movedPermanently :: Response headers body | r1)

#found Source

found :: forall body r1. body -> Variant (found :: Response () body | r1)

#foundWith Source

foundWith :: forall headers body r1. Record headers -> body -> Variant (found :: Response headers body | r1)

#seeOther Source

seeOther :: forall body r1. body -> Variant (seeOther :: Response () body | r1)

#seeOtherWith Source

seeOtherWith :: forall headers body r1. Record headers -> body -> Variant (seeOther :: Response headers body | r1)

#notModified Source

notModified :: forall body r1. body -> Variant (notModified :: Response () body | r1)

#notModifiedWith Source

notModifiedWith :: forall headers body r1. Record headers -> body -> Variant (notModified :: Response headers body | r1)

#useProxy Source

useProxy :: forall body r1. body -> Variant (useProxy :: Response () body | r1)

#useProxyWith Source

useProxyWith :: forall headers body r1. Record headers -> body -> Variant (useProxy :: Response headers body | r1)

#temporaryRedirect Source

temporaryRedirect :: forall body r1. body -> Variant (temporaryRedirect :: Response () body | r1)

#temporaryRedirectWith Source

temporaryRedirectWith :: forall headers body r1. Record headers -> body -> Variant (temporaryRedirect :: Response headers body | r1)

#permanentRedirect Source

permanentRedirect :: forall body r1. body -> Variant (permanentRedirect :: Response () body | r1)

#permanentRedirectWith Source

permanentRedirectWith :: forall headers body r1. Record headers -> body -> Variant (permanentRedirect :: Response headers body | r1)

#badRequest Source

badRequest :: forall body r1. body -> Variant (badRequest :: Response () body | r1)

#badRequestWith Source

badRequestWith :: forall headers body r1. Record headers -> body -> Variant (badRequest :: Response headers body | r1)

#unauthorized Source

unauthorized :: forall body r1. body -> Variant (unauthorized :: Response () body | r1)

#unauthorizedWith Source

unauthorizedWith :: forall headers body r1. Record headers -> body -> Variant (unauthorized :: Response headers body | r1)

#paymentRequired Source

paymentRequired :: forall body r1. body -> Variant (paymentRequired :: Response () body | r1)

#paymentRequiredWith Source

paymentRequiredWith :: forall headers body r1. Record headers -> body -> Variant (paymentRequired :: Response headers body | r1)

#forbidden Source

forbidden :: forall body r1. body -> Variant (forbidden :: Response () body | r1)

#forbiddenWith Source

forbiddenWith :: forall headers body r1. Record headers -> body -> Variant (forbidden :: Response headers body | r1)

#notFound Source

notFound :: forall body r1. body -> Variant (notFound :: Response () body | r1)

#notFoundWith Source

notFoundWith :: forall headers body r1. Record headers -> body -> Variant (notFound :: Response headers body | r1)

#methodNotAllowed Source

methodNotAllowed :: forall body r1. body -> Variant (methodNotAllowed :: Response () body | r1)

#methodNotAllowedWith Source

methodNotAllowedWith :: forall headers body r1. Record headers -> body -> Variant (methodNotAllowed :: Response headers body | r1)

#notAcceptable Source

notAcceptable :: forall body r1. body -> Variant (notAcceptable :: Response () body | r1)

#notAcceptableWith Source

notAcceptableWith :: forall headers body r1. Record headers -> body -> Variant (notAcceptable :: Response headers body | r1)

#proxyAuthenticationRequired Source

proxyAuthenticationRequired :: forall body r1. body -> Variant (proxyAuthenticationRequired :: Response () body | r1)

#proxyAuthenticationRequiredWith Source

proxyAuthenticationRequiredWith :: forall headers body r1. Record headers -> body -> Variant (proxyAuthenticationRequired :: Response headers body | r1)

#requestTimeout Source

requestTimeout :: forall body r1. body -> Variant (requestTimeout :: Response () body | r1)

#requestTimeoutWith Source

requestTimeoutWith :: forall headers body r1. Record headers -> body -> Variant (requestTimeout :: Response headers body | r1)

#conflict Source

conflict :: forall body r1. body -> Variant (conflict :: Response () body | r1)

#conflictWith Source

conflictWith :: forall headers body r1. Record headers -> body -> Variant (conflict :: Response headers body | r1)

#gone Source

gone :: forall body r1. body -> Variant (gone :: Response () body | r1)

#goneWith Source

goneWith :: forall headers body r1. Record headers -> body -> Variant (gone :: Response headers body | r1)

#lengthRequired Source

lengthRequired :: forall body r1. body -> Variant (lengthRequired :: Response () body | r1)

#lengthRequiredWith Source

lengthRequiredWith :: forall headers body r1. Record headers -> body -> Variant (lengthRequired :: Response headers body | r1)

#preconditionFailed Source

preconditionFailed :: forall body r1. body -> Variant (preconditionFailed :: Response () body | r1)

#preconditionFailedWith Source

preconditionFailedWith :: forall headers body r1. Record headers -> body -> Variant (preconditionFailed :: Response headers body | r1)

#payloadTooLarge Source

payloadTooLarge :: forall body r1. body -> Variant (payloadTooLarge :: Response () body | r1)

#payloadTooLargeWith Source

payloadTooLargeWith :: forall headers body r1. Record headers -> body -> Variant (payloadTooLarge :: Response headers body | r1)

#uriTooLong Source

uriTooLong :: forall body r1. body -> Variant (uriTooLong :: Response () body | r1)

#uriTooLongWith Source

uriTooLongWith :: forall headers body r1. Record headers -> body -> Variant (uriTooLong :: Response headers body | r1)

#unsupportedMediaType Source

unsupportedMediaType :: forall body r1. body -> Variant (unsupportedMediaType :: Response () body | r1)

#unsupportedMediaTypeWith Source

unsupportedMediaTypeWith :: forall headers body r1. Record headers -> body -> Variant (unsupportedMediaType :: Response headers body | r1)

#rangeNotSatisfiable Source

rangeNotSatisfiable :: forall body r1. body -> Variant (rangeNotSatisfiable :: Response () body | r1)

#rangeNotSatisfiableWith Source

rangeNotSatisfiableWith :: forall headers body r1. Record headers -> body -> Variant (rangeNotSatisfiable :: Response headers body | r1)

#expectationFailed Source

expectationFailed :: forall body r1. body -> Variant (expectationFailed :: Response () body | r1)

#expectationFailedWith Source

expectationFailedWith :: forall headers body r1. Record headers -> body -> Variant (expectationFailed :: Response headers body | r1)

#imATeapot Source

imATeapot :: forall body r1. body -> Variant (imATeapot :: Response () body | r1)

#imATeapotWith Source

imATeapotWith :: forall headers body r1. Record headers -> body -> Variant (imATeapot :: Response headers body | r1)

#misdirectedRequest Source

misdirectedRequest :: forall body r1. body -> Variant (misdirectedRequest :: Response () body | r1)

#misdirectedRequestWith Source

misdirectedRequestWith :: forall headers body r1. Record headers -> body -> Variant (misdirectedRequest :: Response headers body | r1)

#unprocessableEntity Source

unprocessableEntity :: forall body r1. body -> Variant (unprocessableEntity :: Response () body | r1)

#unprocessableEntityWith Source

unprocessableEntityWith :: forall headers body r1. Record headers -> body -> Variant (unprocessableEntity :: Response headers body | r1)

#locked Source

locked :: forall body r1. body -> Variant (locked :: Response () body | r1)

#lockedWith Source

lockedWith :: forall headers body r1. Record headers -> body -> Variant (locked :: Response headers body | r1)

#failedDependency Source

failedDependency :: forall body r1. body -> Variant (failedDependency :: Response () body | r1)

#failedDependencyWith Source

failedDependencyWith :: forall headers body r1. Record headers -> body -> Variant (failedDependency :: Response headers body | r1)

#tooEarly Source

tooEarly :: forall body r1. body -> Variant (tooEarly :: Response () body | r1)

#tooEarlyWith Source

tooEarlyWith :: forall headers body r1. Record headers -> body -> Variant (tooEarly :: Response headers body | r1)

#upgradeRequired Source

upgradeRequired :: forall body r1. body -> Variant (upgradeRequired :: Response () body | r1)

#upgradeRequiredWith Source

upgradeRequiredWith :: forall headers body r1. Record headers -> body -> Variant (upgradeRequired :: Response headers body | r1)

#preconditionRequired Source

preconditionRequired :: forall body r1. body -> Variant (preconditionRequired :: Response () body | r1)

#preconditionRequiredWith Source

preconditionRequiredWith :: forall headers body r1. Record headers -> body -> Variant (preconditionRequired :: Response headers body | r1)

#tooManyRequests Source

tooManyRequests :: forall body r1. body -> Variant (tooManyRequests :: Response () body | r1)

#tooManyRequestsWith Source

tooManyRequestsWith :: forall headers body r1. Record headers -> body -> Variant (tooManyRequests :: Response headers body | r1)

#requestHeaderFieldsTooLarge Source

requestHeaderFieldsTooLarge :: forall body r1. body -> Variant (requestHeaderFieldsTooLarge :: Response () body | r1)

#requestHeaderFieldsTooLargeWith Source

requestHeaderFieldsTooLargeWith :: forall headers body r1. Record headers -> body -> Variant (requestHeaderFieldsTooLarge :: Response headers body | r1)

#unavailableForLegalReasons Source

unavailableForLegalReasons :: forall body r1. body -> Variant (unavailableForLegalReasons :: Response () body | r1)

#unavailableForLegalReasonsWith Source

unavailableForLegalReasonsWith :: forall headers body r1. Record headers -> body -> Variant (unavailableForLegalReasons :: Response headers body | r1)

#internalServerError Source

internalServerError :: forall body r1. body -> Variant (internalServerError :: Response () body | r1)

#internalServerErrorWith Source

internalServerErrorWith :: forall headers body r1. Record headers -> body -> Variant (internalServerError :: Response headers body | r1)

#notImplemented Source

notImplemented :: forall body r1. body -> Variant (notImplemented :: Response () body | r1)

#notImplementedWith Source

notImplementedWith :: forall headers body r1. Record headers -> body -> Variant (notImplemented :: Response headers body | r1)

#badGateway Source

badGateway :: forall body r1. body -> Variant (badGateway :: Response () body | r1)

#badGatewayWith Source

badGatewayWith :: forall headers body r1. Record headers -> body -> Variant (badGateway :: Response headers body | r1)

#serviceUnavailable Source

serviceUnavailable :: forall body r1. body -> Variant (serviceUnavailable :: Response () body | r1)

#serviceUnavailableWith Source

serviceUnavailableWith :: forall headers body r1. Record headers -> body -> Variant (serviceUnavailable :: Response headers body | r1)

#gatewayTimeout Source

gatewayTimeout :: forall body r1. body -> Variant (gatewayTimeout :: Response () body | r1)

#gatewayTimeoutWith Source

gatewayTimeoutWith :: forall headers body r1. Record headers -> body -> Variant (gatewayTimeout :: Response headers body | r1)

#httpVersionNotSupported Source

httpVersionNotSupported :: forall body r1. body -> Variant (httpVersionNotSupported :: Response () body | r1)

#httpVersionNotSupportedWith Source

httpVersionNotSupportedWith :: forall headers body r1. Record headers -> body -> Variant (httpVersionNotSupported :: Response headers body | r1)

#variantAlsoNegotiates Source

variantAlsoNegotiates :: forall body r1. body -> Variant (variantAlsoNegotiates :: Response () body | r1)

#variantAlsoNegotiatesWith Source

variantAlsoNegotiatesWith :: forall headers body r1. Record headers -> body -> Variant (variantAlsoNegotiates :: Response headers body | r1)

#insufficientStorage Source

insufficientStorage :: forall body r1. body -> Variant (insufficientStorage :: Response () body | r1)

#insufficientStorageWith Source

insufficientStorageWith :: forall headers body r1. Record headers -> body -> Variant (insufficientStorage :: Response headers body | r1)

#loopDetected Source

loopDetected :: forall body r1. body -> Variant (loopDetected :: Response () body | r1)

#loopDetectedWith Source

loopDetectedWith :: forall headers body r1. Record headers -> body -> Variant (loopDetected :: Response headers body | r1)

#notExtended Source

notExtended :: forall body r1. body -> Variant (notExtended :: Response () body | r1)

#notExtendedWith Source

notExtendedWith :: forall headers body r1. Record headers -> body -> Variant (notExtended :: Response headers body | r1)

#networkAuthenticationRequired Source

networkAuthenticationRequired :: forall body r1. body -> Variant (networkAuthenticationRequired :: Response () body | r1)

#networkAuthenticationRequiredWith Source

networkAuthenticationRequiredWith :: forall headers body r1. Record headers -> body -> Variant (networkAuthenticationRequired :: Response headers body | r1)

Re-exports from Data.Variant