Make response helpers API consistent (#79)
This commit is contained in:
parent
f4599b276b
commit
8760334dcd
@ -35,7 +35,7 @@ headerMiddleware :: forall e.
|
||||
HTTPure.ResponseM e
|
||||
headerMiddleware router request = do
|
||||
response <- router request
|
||||
HTTPure.response response.status (header <> response.headers) response.body
|
||||
HTTPure.response' response.status (header <> response.headers) response.body
|
||||
where
|
||||
header = HTTPure.headers [ Tuple.Tuple "X-Middleware" "middleware" ]
|
||||
|
||||
|
@ -16,6 +16,7 @@ import HTTPure.Request (Request)
|
||||
import HTTPure.Response
|
||||
( ResponseM
|
||||
, response, response'
|
||||
, emptyResponse, emptyResponse'
|
||||
|
||||
-- 1xx
|
||||
, continue, continue'
|
||||
|
@ -3,6 +3,7 @@ module HTTPure.Response
|
||||
, ResponseM
|
||||
, send
|
||||
, response, response'
|
||||
, emptyResponse, emptyResponse'
|
||||
|
||||
-- 1xx
|
||||
, continue, continue'
|
||||
@ -112,16 +113,24 @@ send httpresponse { status, headers, body } = do
|
||||
|
||||
-- | For custom response statuses or providing a body for response codes that
|
||||
-- | don't typically send one.
|
||||
response :: forall e.
|
||||
Status.Status ->
|
||||
Headers.Headers ->
|
||||
Body.Body ->
|
||||
ResponseM e
|
||||
response status headers body = pure $ { status, headers, body }
|
||||
response :: forall e. Status.Status -> Body.Body -> ResponseM e
|
||||
response status = response' status Headers.empty
|
||||
|
||||
-- | The same as `response` but with headers.
|
||||
response' :: forall e.
|
||||
Status.Status ->
|
||||
Headers.Headers ->
|
||||
Body.Body ->
|
||||
ResponseM e
|
||||
response' status headers body = pure $ { status, headers, body }
|
||||
|
||||
-- | The same as `response` but without a body.
|
||||
response' :: forall e. Status.Status -> Headers.Headers -> ResponseM e
|
||||
response' status headers = response status headers $ ""
|
||||
emptyResponse :: forall e. Status.Status -> ResponseM e
|
||||
emptyResponse status = emptyResponse' status Headers.empty
|
||||
|
||||
-- | The same as `emptyResponse` but with headers.
|
||||
emptyResponse' :: forall e. Status.Status -> Headers.Headers -> ResponseM e
|
||||
emptyResponse' status headers = response' status headers ""
|
||||
|
||||
---------
|
||||
-- 1xx --
|
||||
@ -133,7 +142,7 @@ continue = continue' Headers.empty
|
||||
|
||||
-- | 100 with headers
|
||||
continue' :: forall e. Headers.Headers -> ResponseM e
|
||||
continue' = response' Status.continue
|
||||
continue' = emptyResponse' Status.continue
|
||||
|
||||
-- | 101
|
||||
switchingProtocols :: forall e. ResponseM e
|
||||
@ -141,7 +150,7 @@ switchingProtocols = switchingProtocols' Headers.empty
|
||||
|
||||
-- | 101 with headers
|
||||
switchingProtocols' :: forall e. Headers.Headers -> ResponseM e
|
||||
switchingProtocols' = response' Status.switchingProtocols
|
||||
switchingProtocols' = emptyResponse' Status.switchingProtocols
|
||||
|
||||
-- | 102
|
||||
processing :: forall e. ResponseM e
|
||||
@ -149,7 +158,7 @@ processing = processing' Headers.empty
|
||||
|
||||
-- | 102 with headers
|
||||
processing' :: forall e. Headers.Headers -> ResponseM e
|
||||
processing' = response' Status.processing
|
||||
processing' = emptyResponse' Status.processing
|
||||
|
||||
---------
|
||||
-- 2xx --
|
||||
@ -161,7 +170,7 @@ ok = ok' Headers.empty
|
||||
|
||||
-- | 200 with headers
|
||||
ok' :: forall e. Headers.Headers -> Body.Body -> ResponseM e
|
||||
ok' = response Status.ok
|
||||
ok' = response' Status.ok
|
||||
|
||||
-- | 201
|
||||
created :: forall e. ResponseM e
|
||||
@ -169,7 +178,7 @@ created = created' Headers.empty
|
||||
|
||||
-- | 201 with headers
|
||||
created' :: forall e. Headers.Headers -> ResponseM e
|
||||
created' = response' Status.created
|
||||
created' = emptyResponse' Status.created
|
||||
|
||||
-- | 202
|
||||
accepted :: forall e. ResponseM e
|
||||
@ -177,7 +186,7 @@ accepted = accepted' Headers.empty
|
||||
|
||||
-- | 202 with headers
|
||||
accepted' :: forall e. Headers.Headers -> ResponseM e
|
||||
accepted' = response' Status.accepted
|
||||
accepted' = emptyResponse' Status.accepted
|
||||
|
||||
-- | 203
|
||||
nonAuthoritativeInformation :: forall e. Body.Body -> ResponseM e
|
||||
@ -188,7 +197,7 @@ nonAuthoritativeInformation' :: forall e.
|
||||
Headers.Headers ->
|
||||
Body.Body ->
|
||||
ResponseM e
|
||||
nonAuthoritativeInformation' = response Status.nonAuthoritativeInformation
|
||||
nonAuthoritativeInformation' = response' Status.nonAuthoritativeInformation
|
||||
|
||||
-- | 204
|
||||
noContent :: forall e. ResponseM e
|
||||
@ -196,7 +205,7 @@ noContent = noContent' Headers.empty
|
||||
|
||||
-- | 204 with headers
|
||||
noContent' :: forall e. Headers.Headers -> ResponseM e
|
||||
noContent' = response' Status.noContent
|
||||
noContent' = emptyResponse' Status.noContent
|
||||
|
||||
-- | 205
|
||||
resetContent :: forall e. ResponseM e
|
||||
@ -204,7 +213,7 @@ resetContent = resetContent' Headers.empty
|
||||
|
||||
-- | 205 with headers
|
||||
resetContent' :: forall e. Headers.Headers -> ResponseM e
|
||||
resetContent' = response' Status.resetContent
|
||||
resetContent' = emptyResponse' Status.resetContent
|
||||
|
||||
-- | 206
|
||||
partialContent :: forall e. Body.Body -> ResponseM e
|
||||
@ -212,7 +221,7 @@ partialContent = partialContent' Headers.empty
|
||||
|
||||
-- | 206 with headers
|
||||
partialContent' :: forall e. Headers.Headers -> Body.Body -> ResponseM e
|
||||
partialContent' = response Status.partialContent
|
||||
partialContent' = response' Status.partialContent
|
||||
|
||||
-- | 207
|
||||
multiStatus :: forall e. Body.Body -> ResponseM e
|
||||
@ -220,7 +229,7 @@ multiStatus = multiStatus' Headers.empty
|
||||
|
||||
-- | 207 with headers
|
||||
multiStatus' :: forall e. Headers.Headers -> Body.Body -> ResponseM e
|
||||
multiStatus' = response Status.multiStatus
|
||||
multiStatus' = response' Status.multiStatus
|
||||
|
||||
-- | 208
|
||||
alreadyReported :: forall e. ResponseM e
|
||||
@ -228,7 +237,7 @@ alreadyReported = alreadyReported' Headers.empty
|
||||
|
||||
-- | 208 with headers
|
||||
alreadyReported' :: forall e. Headers.Headers -> ResponseM e
|
||||
alreadyReported' = response' Status.alreadyReported
|
||||
alreadyReported' = emptyResponse' Status.alreadyReported
|
||||
|
||||
-- | 226
|
||||
iMUsed :: forall e. Body.Body -> ResponseM e
|
||||
@ -236,7 +245,7 @@ iMUsed = iMUsed' Headers.empty
|
||||
|
||||
-- | 226 with headers
|
||||
iMUsed' :: forall e. Headers.Headers -> Body.Body -> ResponseM e
|
||||
iMUsed' = response Status.iMUsed
|
||||
iMUsed' = response' Status.iMUsed
|
||||
|
||||
---------
|
||||
-- 3xx --
|
||||
@ -248,7 +257,7 @@ multipleChoices = multipleChoices' Headers.empty
|
||||
|
||||
-- | 300 with headers
|
||||
multipleChoices' :: forall e. Headers.Headers -> Body.Body -> ResponseM e
|
||||
multipleChoices' = response Status.multipleChoices
|
||||
multipleChoices' = response' Status.multipleChoices
|
||||
|
||||
-- | 301
|
||||
movedPermanently :: forall e. Body.Body -> ResponseM e
|
||||
@ -256,7 +265,7 @@ movedPermanently = movedPermanently' Headers.empty
|
||||
|
||||
-- | 301 with headers
|
||||
movedPermanently' :: forall e. Headers.Headers -> Body.Body -> ResponseM e
|
||||
movedPermanently' = response Status.movedPermanently
|
||||
movedPermanently' = response' Status.movedPermanently
|
||||
|
||||
-- | 302
|
||||
found :: forall e. Body.Body -> ResponseM e
|
||||
@ -264,7 +273,7 @@ found = found' Headers.empty
|
||||
|
||||
-- | 302 with headers
|
||||
found' :: forall e. Headers.Headers -> Body.Body -> ResponseM e
|
||||
found' = response Status.found
|
||||
found' = response' Status.found
|
||||
|
||||
-- | 303
|
||||
seeOther :: forall e. Body.Body -> ResponseM e
|
||||
@ -272,7 +281,7 @@ seeOther = seeOther' Headers.empty
|
||||
|
||||
-- | 303 with headers
|
||||
seeOther' :: forall e. Headers.Headers -> Body.Body -> ResponseM e
|
||||
seeOther' = response Status.seeOther
|
||||
seeOther' = response' Status.seeOther
|
||||
|
||||
-- | 304
|
||||
notModified :: forall e. ResponseM e
|
||||
@ -280,7 +289,7 @@ notModified = notModified' Headers.empty
|
||||
|
||||
-- | 304 with headers
|
||||
notModified' :: forall e. Headers.Headers -> ResponseM e
|
||||
notModified' = response' Status.notModified
|
||||
notModified' = emptyResponse' Status.notModified
|
||||
|
||||
-- | 305
|
||||
useProxy :: forall e. Body.Body -> ResponseM e
|
||||
@ -288,7 +297,7 @@ useProxy = useProxy' Headers.empty
|
||||
|
||||
-- | 305 with headers
|
||||
useProxy' :: forall e. Headers.Headers -> Body.Body -> ResponseM e
|
||||
useProxy' = response Status.useProxy
|
||||
useProxy' = response' Status.useProxy
|
||||
|
||||
-- | 307
|
||||
temporaryRedirect :: forall e. Body.Body -> ResponseM e
|
||||
@ -296,7 +305,7 @@ temporaryRedirect = temporaryRedirect' Headers.empty
|
||||
|
||||
-- | 307 with headers
|
||||
temporaryRedirect' :: forall e. Headers.Headers -> Body.Body -> ResponseM e
|
||||
temporaryRedirect' = response Status.temporaryRedirect
|
||||
temporaryRedirect' = response' Status.temporaryRedirect
|
||||
|
||||
-- | 308
|
||||
permanentRedirect :: forall e. Body.Body -> ResponseM e
|
||||
@ -304,7 +313,7 @@ permanentRedirect = permanentRedirect' Headers.empty
|
||||
|
||||
-- | 308 with headers
|
||||
permanentRedirect' :: forall e. Headers.Headers -> Body.Body -> ResponseM e
|
||||
permanentRedirect' = response Status.permanentRedirect
|
||||
permanentRedirect' = response' Status.permanentRedirect
|
||||
|
||||
|
||||
---------
|
||||
@ -317,7 +326,7 @@ badRequest = badRequest' Headers.empty
|
||||
|
||||
-- | 400 with headers
|
||||
badRequest' :: forall e. Headers.Headers -> Body.Body -> ResponseM e
|
||||
badRequest' = response Status.badRequest
|
||||
badRequest' = response' Status.badRequest
|
||||
|
||||
-- | 401
|
||||
unauthorized :: forall e. ResponseM e
|
||||
@ -325,7 +334,7 @@ unauthorized = unauthorized' Headers.empty
|
||||
|
||||
-- | 401 with headers
|
||||
unauthorized' :: forall e. Headers.Headers -> ResponseM e
|
||||
unauthorized' = response' Status.unauthorized
|
||||
unauthorized' = emptyResponse' Status.unauthorized
|
||||
|
||||
-- | 402
|
||||
paymentRequired :: forall e. ResponseM e
|
||||
@ -333,7 +342,7 @@ paymentRequired = paymentRequired' Headers.empty
|
||||
|
||||
-- | 402 with headers
|
||||
paymentRequired' :: forall e. Headers.Headers -> ResponseM e
|
||||
paymentRequired' = response' Status.paymentRequired
|
||||
paymentRequired' = emptyResponse' Status.paymentRequired
|
||||
|
||||
-- | 403
|
||||
forbidden :: forall e. ResponseM e
|
||||
@ -341,7 +350,7 @@ forbidden = forbidden' Headers.empty
|
||||
|
||||
-- | 403 with headers
|
||||
forbidden' :: forall e. Headers.Headers -> ResponseM e
|
||||
forbidden' = response' Status.forbidden
|
||||
forbidden' = emptyResponse' Status.forbidden
|
||||
|
||||
-- | 404
|
||||
notFound :: forall e. ResponseM e
|
||||
@ -349,7 +358,7 @@ notFound = notFound' Headers.empty
|
||||
|
||||
-- | 404 with headers
|
||||
notFound' :: forall e. Headers.Headers -> ResponseM e
|
||||
notFound' = response' Status.notFound
|
||||
notFound' = emptyResponse' Status.notFound
|
||||
|
||||
-- | 405
|
||||
methodNotAllowed :: forall e. ResponseM e
|
||||
@ -357,7 +366,7 @@ methodNotAllowed = methodNotAllowed' Headers.empty
|
||||
|
||||
-- | 405 with headers
|
||||
methodNotAllowed' :: forall e. Headers.Headers -> ResponseM e
|
||||
methodNotAllowed' = response' Status.methodNotAllowed
|
||||
methodNotAllowed' = emptyResponse' Status.methodNotAllowed
|
||||
|
||||
-- | 406
|
||||
notAcceptable :: forall e. ResponseM e
|
||||
@ -365,7 +374,7 @@ notAcceptable = notAcceptable' Headers.empty
|
||||
|
||||
-- | 406 with headers
|
||||
notAcceptable' :: forall e. Headers.Headers -> ResponseM e
|
||||
notAcceptable' = response' Status.notAcceptable
|
||||
notAcceptable' = emptyResponse' Status.notAcceptable
|
||||
|
||||
-- | 407
|
||||
proxyAuthenticationRequired :: forall e. ResponseM e
|
||||
@ -373,7 +382,7 @@ proxyAuthenticationRequired = proxyAuthenticationRequired' Headers.empty
|
||||
|
||||
-- | 407 with headers
|
||||
proxyAuthenticationRequired' :: forall e. Headers.Headers -> ResponseM e
|
||||
proxyAuthenticationRequired' = response' Status.proxyAuthenticationRequired
|
||||
proxyAuthenticationRequired' = emptyResponse' Status.proxyAuthenticationRequired
|
||||
|
||||
-- | 408
|
||||
requestTimeout :: forall e. ResponseM e
|
||||
@ -381,7 +390,7 @@ requestTimeout = requestTimeout' Headers.empty
|
||||
|
||||
-- | 408 with headers
|
||||
requestTimeout' :: forall e. Headers.Headers -> ResponseM e
|
||||
requestTimeout' = response' Status.requestTimeout
|
||||
requestTimeout' = emptyResponse' Status.requestTimeout
|
||||
|
||||
-- | 409
|
||||
conflict :: forall e. Body.Body -> ResponseM e
|
||||
@ -389,7 +398,7 @@ conflict = conflict' Headers.empty
|
||||
|
||||
-- | 409 with headers
|
||||
conflict' :: forall e. Headers.Headers -> Body.Body -> ResponseM e
|
||||
conflict' = response Status.conflict
|
||||
conflict' = response' Status.conflict
|
||||
|
||||
-- | 410
|
||||
gone :: forall e. ResponseM e
|
||||
@ -397,7 +406,7 @@ gone = gone' Headers.empty
|
||||
|
||||
-- | 410 with headers
|
||||
gone' :: forall e. Headers.Headers -> ResponseM e
|
||||
gone' = response' Status.gone
|
||||
gone' = emptyResponse' Status.gone
|
||||
|
||||
-- | 411
|
||||
lengthRequired :: forall e. ResponseM e
|
||||
@ -405,7 +414,7 @@ lengthRequired = lengthRequired' Headers.empty
|
||||
|
||||
-- | 411 with headers
|
||||
lengthRequired' :: forall e. Headers.Headers -> ResponseM e
|
||||
lengthRequired' = response' Status.lengthRequired
|
||||
lengthRequired' = emptyResponse' Status.lengthRequired
|
||||
|
||||
-- | 412
|
||||
preconditionFailed :: forall e. ResponseM e
|
||||
@ -413,7 +422,7 @@ preconditionFailed = preconditionFailed' Headers.empty
|
||||
|
||||
-- | 412 with headers
|
||||
preconditionFailed' :: forall e. Headers.Headers -> ResponseM e
|
||||
preconditionFailed' = response' Status.preconditionFailed
|
||||
preconditionFailed' = emptyResponse' Status.preconditionFailed
|
||||
|
||||
-- | 413
|
||||
payloadTooLarge :: forall e. ResponseM e
|
||||
@ -421,7 +430,7 @@ payloadTooLarge = payloadTooLarge' Headers.empty
|
||||
|
||||
-- | 413 with headers
|
||||
payloadTooLarge' :: forall e. Headers.Headers -> ResponseM e
|
||||
payloadTooLarge' = response' Status.payloadTooLarge
|
||||
payloadTooLarge' = emptyResponse' Status.payloadTooLarge
|
||||
|
||||
-- | 414
|
||||
uRITooLong :: forall e. ResponseM e
|
||||
@ -429,7 +438,7 @@ uRITooLong = uRITooLong' Headers.empty
|
||||
|
||||
-- | 414 with headers
|
||||
uRITooLong' :: forall e. Headers.Headers -> ResponseM e
|
||||
uRITooLong' = response' Status.uRITooLong
|
||||
uRITooLong' = emptyResponse' Status.uRITooLong
|
||||
|
||||
-- | 415
|
||||
unsupportedMediaType :: forall e. ResponseM e
|
||||
@ -437,7 +446,7 @@ unsupportedMediaType = unsupportedMediaType' Headers.empty
|
||||
|
||||
-- | 415 with headers
|
||||
unsupportedMediaType' :: forall e. Headers.Headers -> ResponseM e
|
||||
unsupportedMediaType' = response' Status.unsupportedMediaType
|
||||
unsupportedMediaType' = emptyResponse' Status.unsupportedMediaType
|
||||
|
||||
-- | 416
|
||||
rangeNotSatisfiable :: forall e. ResponseM e
|
||||
@ -445,7 +454,7 @@ rangeNotSatisfiable = rangeNotSatisfiable' Headers.empty
|
||||
|
||||
-- | 416 with headers
|
||||
rangeNotSatisfiable' :: forall e. Headers.Headers -> ResponseM e
|
||||
rangeNotSatisfiable' = response' Status.rangeNotSatisfiable
|
||||
rangeNotSatisfiable' = emptyResponse' Status.rangeNotSatisfiable
|
||||
|
||||
-- | 417
|
||||
expectationFailed :: forall e. ResponseM e
|
||||
@ -453,7 +462,7 @@ expectationFailed = expectationFailed' Headers.empty
|
||||
|
||||
-- | 417 with headers
|
||||
expectationFailed' :: forall e. Headers.Headers -> ResponseM e
|
||||
expectationFailed' = response' Status.expectationFailed
|
||||
expectationFailed' = emptyResponse' Status.expectationFailed
|
||||
|
||||
-- | 418
|
||||
imATeapot :: forall e. ResponseM e
|
||||
@ -461,7 +470,7 @@ imATeapot = imATeapot' Headers.empty
|
||||
|
||||
-- | 418 with headers
|
||||
imATeapot' :: forall e. Headers.Headers -> ResponseM e
|
||||
imATeapot' = response' Status.imATeapot
|
||||
imATeapot' = emptyResponse' Status.imATeapot
|
||||
|
||||
-- | 421
|
||||
misdirectedRequest :: forall e. ResponseM e
|
||||
@ -469,7 +478,7 @@ misdirectedRequest = misdirectedRequest' Headers.empty
|
||||
|
||||
-- | 421 with headers
|
||||
misdirectedRequest' :: forall e. Headers.Headers -> ResponseM e
|
||||
misdirectedRequest' = response' Status.misdirectedRequest
|
||||
misdirectedRequest' = emptyResponse' Status.misdirectedRequest
|
||||
|
||||
-- | 422
|
||||
unprocessableEntity :: forall e. ResponseM e
|
||||
@ -477,7 +486,7 @@ unprocessableEntity = unprocessableEntity' Headers.empty
|
||||
|
||||
-- | 422 with headers
|
||||
unprocessableEntity' :: forall e. Headers.Headers -> ResponseM e
|
||||
unprocessableEntity' = response' Status.unprocessableEntity
|
||||
unprocessableEntity' = emptyResponse' Status.unprocessableEntity
|
||||
|
||||
-- | 423
|
||||
locked :: forall e. ResponseM e
|
||||
@ -485,7 +494,7 @@ locked = locked' Headers.empty
|
||||
|
||||
-- | 423 with headers
|
||||
locked' :: forall e. Headers.Headers -> ResponseM e
|
||||
locked' = response' Status.locked
|
||||
locked' = emptyResponse' Status.locked
|
||||
|
||||
-- | 424
|
||||
failedDependency :: forall e. ResponseM e
|
||||
@ -493,7 +502,7 @@ failedDependency = failedDependency' Headers.empty
|
||||
|
||||
-- | 424 with headers
|
||||
failedDependency' :: forall e. Headers.Headers -> ResponseM e
|
||||
failedDependency' = response' Status.failedDependency
|
||||
failedDependency' = emptyResponse' Status.failedDependency
|
||||
|
||||
-- | 426
|
||||
upgradeRequired :: forall e. ResponseM e
|
||||
@ -501,7 +510,7 @@ upgradeRequired = upgradeRequired' Headers.empty
|
||||
|
||||
-- | 426 with headers
|
||||
upgradeRequired' :: forall e. Headers.Headers -> ResponseM e
|
||||
upgradeRequired' = response' Status.upgradeRequired
|
||||
upgradeRequired' = emptyResponse' Status.upgradeRequired
|
||||
|
||||
-- | 428
|
||||
preconditionRequired :: forall e. ResponseM e
|
||||
@ -509,7 +518,7 @@ preconditionRequired = preconditionRequired' Headers.empty
|
||||
|
||||
-- | 428 with headers
|
||||
preconditionRequired' :: forall e. Headers.Headers -> ResponseM e
|
||||
preconditionRequired' = response' Status.preconditionRequired
|
||||
preconditionRequired' = emptyResponse' Status.preconditionRequired
|
||||
|
||||
-- | 429
|
||||
tooManyRequests :: forall e. ResponseM e
|
||||
@ -517,7 +526,7 @@ tooManyRequests = tooManyRequests' Headers.empty
|
||||
|
||||
-- | 429 with headers
|
||||
tooManyRequests' :: forall e. Headers.Headers -> ResponseM e
|
||||
tooManyRequests' = response' Status.tooManyRequests
|
||||
tooManyRequests' = emptyResponse' Status.tooManyRequests
|
||||
|
||||
-- | 431
|
||||
requestHeaderFieldsTooLarge :: forall e. ResponseM e
|
||||
@ -525,7 +534,7 @@ requestHeaderFieldsTooLarge = requestHeaderFieldsTooLarge' Headers.empty
|
||||
|
||||
-- | 431 with headers
|
||||
requestHeaderFieldsTooLarge' :: forall e. Headers.Headers -> ResponseM e
|
||||
requestHeaderFieldsTooLarge' = response' Status.requestHeaderFieldsTooLarge
|
||||
requestHeaderFieldsTooLarge' = emptyResponse' Status.requestHeaderFieldsTooLarge
|
||||
|
||||
-- | 451
|
||||
unavailableForLegalReasons :: forall e. ResponseM e
|
||||
@ -533,7 +542,7 @@ unavailableForLegalReasons = unavailableForLegalReasons' Headers.empty
|
||||
|
||||
-- | 451 with headers
|
||||
unavailableForLegalReasons' :: forall e. Headers.Headers -> ResponseM e
|
||||
unavailableForLegalReasons' = response' Status.unavailableForLegalReasons
|
||||
unavailableForLegalReasons' = emptyResponse' Status.unavailableForLegalReasons
|
||||
|
||||
---------
|
||||
-- 5xx --
|
||||
@ -545,7 +554,7 @@ internalServerError = internalServerError' Headers.empty
|
||||
|
||||
-- | 500 with headers
|
||||
internalServerError' :: forall e. Headers.Headers -> Body.Body -> ResponseM e
|
||||
internalServerError' = response Status.internalServerError
|
||||
internalServerError' = response' Status.internalServerError
|
||||
|
||||
-- | 501
|
||||
notImplemented :: forall e. ResponseM e
|
||||
@ -553,7 +562,7 @@ notImplemented = notImplemented' Headers.empty
|
||||
|
||||
-- | 501 with headers
|
||||
notImplemented' :: forall e. Headers.Headers -> ResponseM e
|
||||
notImplemented' = response' Status.notImplemented
|
||||
notImplemented' = emptyResponse' Status.notImplemented
|
||||
|
||||
-- | 502
|
||||
badGateway :: forall e. ResponseM e
|
||||
@ -561,7 +570,7 @@ badGateway = badGateway' Headers.empty
|
||||
|
||||
-- | 502 with headers
|
||||
badGateway' :: forall e. Headers.Headers -> ResponseM e
|
||||
badGateway' = response' Status.badGateway
|
||||
badGateway' = emptyResponse' Status.badGateway
|
||||
|
||||
-- | 503
|
||||
serviceUnavailable :: forall e. ResponseM e
|
||||
@ -569,7 +578,7 @@ serviceUnavailable = serviceUnavailable' Headers.empty
|
||||
|
||||
-- | 503 with headers
|
||||
serviceUnavailable' :: forall e. Headers.Headers -> ResponseM e
|
||||
serviceUnavailable' = response' Status.serviceUnavailable
|
||||
serviceUnavailable' = emptyResponse' Status.serviceUnavailable
|
||||
|
||||
-- | 504
|
||||
gatewayTimeout :: forall e. ResponseM e
|
||||
@ -577,7 +586,7 @@ gatewayTimeout = gatewayTimeout' Headers.empty
|
||||
|
||||
-- | 504 with headers
|
||||
gatewayTimeout' :: forall e. Headers.Headers -> ResponseM e
|
||||
gatewayTimeout' = response' Status.gatewayTimeout
|
||||
gatewayTimeout' = emptyResponse' Status.gatewayTimeout
|
||||
|
||||
-- | 505
|
||||
hTTPVersionNotSupported :: forall e. ResponseM e
|
||||
@ -585,7 +594,7 @@ hTTPVersionNotSupported = hTTPVersionNotSupported' Headers.empty
|
||||
|
||||
-- | 505 with headers
|
||||
hTTPVersionNotSupported' :: forall e. Headers.Headers -> ResponseM e
|
||||
hTTPVersionNotSupported' = response' Status.hTTPVersionNotSupported
|
||||
hTTPVersionNotSupported' = emptyResponse' Status.hTTPVersionNotSupported
|
||||
|
||||
-- | 506
|
||||
variantAlsoNegotiates :: forall e. ResponseM e
|
||||
@ -593,7 +602,7 @@ variantAlsoNegotiates = variantAlsoNegotiates' Headers.empty
|
||||
|
||||
-- | 506 with headers
|
||||
variantAlsoNegotiates' :: forall e. Headers.Headers -> ResponseM e
|
||||
variantAlsoNegotiates' = response' Status.variantAlsoNegotiates
|
||||
variantAlsoNegotiates' = emptyResponse' Status.variantAlsoNegotiates
|
||||
|
||||
-- | 507
|
||||
insufficientStorage :: forall e. ResponseM e
|
||||
@ -601,7 +610,7 @@ insufficientStorage = insufficientStorage' Headers.empty
|
||||
|
||||
-- | 507 with headers
|
||||
insufficientStorage' :: forall e. Headers.Headers -> ResponseM e
|
||||
insufficientStorage' = response' Status.insufficientStorage
|
||||
insufficientStorage' = emptyResponse' Status.insufficientStorage
|
||||
|
||||
-- | 508
|
||||
loopDetected :: forall e. ResponseM e
|
||||
@ -609,7 +618,7 @@ loopDetected = loopDetected' Headers.empty
|
||||
|
||||
-- | 508 with headers
|
||||
loopDetected' :: forall e. Headers.Headers -> ResponseM e
|
||||
loopDetected' = response' Status.loopDetected
|
||||
loopDetected' = emptyResponse' Status.loopDetected
|
||||
|
||||
-- | 510
|
||||
notExtended :: forall e. ResponseM e
|
||||
@ -617,7 +626,7 @@ notExtended = notExtended' Headers.empty
|
||||
|
||||
-- | 510 with headers
|
||||
notExtended' :: forall e. Headers.Headers -> ResponseM e
|
||||
notExtended' = response' Status.notExtended
|
||||
notExtended' = emptyResponse' Status.notExtended
|
||||
|
||||
-- | 511
|
||||
networkAuthenticationRequired :: forall e. ResponseM e
|
||||
@ -625,4 +634,5 @@ networkAuthenticationRequired = networkAuthenticationRequired' Headers.empty
|
||||
|
||||
-- | 511 with headers
|
||||
networkAuthenticationRequired' :: forall e. Headers.Headers -> ResponseM e
|
||||
networkAuthenticationRequired' = response' Status.networkAuthenticationRequired
|
||||
networkAuthenticationRequired' =
|
||||
emptyResponse' Status.networkAuthenticationRequired
|
||||
|
@ -37,6 +37,18 @@ sendSpec = Spec.describe "send" do
|
||||
|
||||
responseFunctionSpec :: SpecHelpers.Test
|
||||
responseFunctionSpec = Spec.describe "response" do
|
||||
Spec.it "has the right status" do
|
||||
resp <- Response.response 123 "test"
|
||||
resp.status ?= 123
|
||||
Spec.it "has empty headers" do
|
||||
resp <- Response.response 123 "test"
|
||||
resp.headers ?= Headers.empty
|
||||
Spec.it "has the right body" do
|
||||
resp <- Response.response 123 "test"
|
||||
resp.body ?= "test"
|
||||
|
||||
response'Spec :: SpecHelpers.Test
|
||||
response'Spec = Spec.describe "response'" do
|
||||
Spec.it "has the right status" do
|
||||
resp <- mockResponse
|
||||
resp.status ?= 123
|
||||
@ -48,10 +60,22 @@ responseFunctionSpec = Spec.describe "response" do
|
||||
resp.body ?= "test"
|
||||
where
|
||||
mockHeaders = Headers.header "Test" "test"
|
||||
mockResponse = Response.response 123 mockHeaders "test"
|
||||
mockResponse = Response.response' 123 mockHeaders "test"
|
||||
|
||||
response'Spec :: SpecHelpers.Test
|
||||
response'Spec = Spec.describe "response'" do
|
||||
emptyResponseSpec :: SpecHelpers.Test
|
||||
emptyResponseSpec = Spec.describe "emptyResponse" do
|
||||
Spec.it "has the right status" do
|
||||
resp <- Response.emptyResponse 123
|
||||
resp.status ?= 123
|
||||
Spec.it "has empty headers" do
|
||||
resp <- Response.emptyResponse 123
|
||||
resp.headers ?= Headers.empty
|
||||
Spec.it "has an empty body" do
|
||||
resp <- Response.emptyResponse 123
|
||||
resp.body ?= ""
|
||||
|
||||
emptyResponse'Spec :: SpecHelpers.Test
|
||||
emptyResponse'Spec = Spec.describe "emptyResponse'" do
|
||||
Spec.it "has the right status" do
|
||||
resp <- mockResponse
|
||||
resp.status ?= 123
|
||||
@ -63,10 +87,12 @@ response'Spec = Spec.describe "response'" do
|
||||
resp.body ?= ""
|
||||
where
|
||||
mockHeaders = Headers.header "Test" "test"
|
||||
mockResponse = Response.response' 123 mockHeaders
|
||||
mockResponse = Response.emptyResponse' 123 mockHeaders
|
||||
|
||||
responseSpec :: SpecHelpers.Test
|
||||
responseSpec = Spec.describe "Response" do
|
||||
sendSpec
|
||||
responseFunctionSpec
|
||||
response'Spec
|
||||
emptyResponseSpec
|
||||
emptyResponse'Spec
|
||||
|
Loading…
Reference in New Issue
Block a user