Definition of HTTP status codes.
- class (Eq sc, Show sc) => StatusCode sc where
- numericCode :: sc -> Int
- textualStatus :: sc -> AsciiBuilder
- fromStatusCode :: sc -> SomeStatusCode
- data SomeStatusCode
- statusCodes :: QuasiQuoter
- data Continue = Continue
- data SwitchingProtocols = SwitchingProtocols
- data Processing = Processing
- data OK = OK
- data Created = Created
- data Accepted = Accepted
- data NonAuthoritativeInformation = NonAuthoritativeInformation
- data NoContent = NoContent
- data ResetContent = ResetContent
- data PartialContent = PartialContent
- data MultiStatus = MultiStatus
- data AlreadyReported = AlreadyReported
- data IMUsed = IMUsed
- data MultipleChoices = MultipleChoices
- data MovedPermanently = MovedPermanently
- data Found = Found
- data SeeOther = SeeOther
- data NotModified = NotModified
- data UseProxy = UseProxy
- data TemporaryRedirect = TemporaryRedirect
- data BadRequest = BadRequest
- data Unauthorized = Unauthorized
- data PaymentRequired = PaymentRequired
- data Forbidden = Forbidden
- data NotFound = NotFound
- data MethodNotAllowed = MethodNotAllowed
- data NotAcceptable = NotAcceptable
- data ProxyAuthenticationRequired = ProxyAuthenticationRequired
- data RequestTimeout = RequestTimeout
- data Conflict = Conflict
- data Gone = Gone
- data LengthRequired = LengthRequired
- data PreconditionFailed = PreconditionFailed
- data RequestEntityTooLarge = RequestEntityTooLarge
- data RequestURITooLarge = RequestURITooLarge
- data UnsupportedMediaType = UnsupportedMediaType
- data RequestRangeNotSatisfiable = RequestRangeNotSatisfiable
- data ExpectationFailed = ExpectationFailed
- data UnprocessableEntity = UnprocessableEntity
- data Locked = Locked
- data FailedDependency = FailedDependency
- data UpgradeRequired = UpgradeRequired
- data InternalServerError = InternalServerError
- data NotImplemented = NotImplemented
- data BadGateway = BadGateway
- data ServiceUnavailable = ServiceUnavailable
- data GatewayTimeout = GatewayTimeout
- data HTTPVersionNotSupported = HTTPVersionNotSupported
- data VariantAlsoNegotiates = VariantAlsoNegotiates
- data InsufficientStorage = InsufficientStorage
- data LoopDetected = LoopDetected
- data NotExtended = NotExtended
Type class
class (Eq sc, Show sc) => StatusCode sc whereSource
Type class for HTTP status codes.
Declaring types for each statuses is surely a pain. See:
statusCodes
quasi-quoter.
Minimal complete definition: numericCode
and textualStatus
.
numericCode :: sc -> IntSource
Return the 3-digit integer for this status e.g. 200
textualStatus :: sc -> AsciiBuilderSource
Return the combination of 3-digit integer and reason phrase
for this status e.g. 200 OK
fromStatusCode :: sc -> SomeStatusCodeSource
Wrap the status code into SomeStatusCode
.
data SomeStatusCode Source
Container type for the StatusCode
type class.
Eq SomeStatusCode | Equivalence of |
Show SomeStatusCode | |
StatusCode SomeStatusCode | |
StatusCode sc => ConvertSuccess sc SomeStatusCode | |
StatusCode sc => ConvertAttempt sc SomeStatusCode |
statusCodes :: QuasiQuoterSource
QuasiQuoter
for StatusCode
declarations.
Top-level splicing
[statusCodes
|
200 OK
400 Bad Request
405 Method Not Allowed
|]
becomes:
data OK = OK deriving (Eq
,Show
) instanceStatusCode
OK wherenumericCode
_ = 200textualStatus
_ =cs
("200 OK" Ascii) data BadRequest = BadRequest deriving (Eq
,Show
) instanceStatusCode
BadRequest wherenumericCode
_ = 400textualStatus
_ =cs
("400 Bad Request" Ascii) data MethodNotAllowed = MethodNotAllowed deriving (Eq
,Show
) instanceStatusCode
MethodNotAllowed wherenumericCode
_ = 405textualStatus
_ =cs
("405 Method Not Allowed" Ascii)
Status codes
Informational
data SwitchingProtocols Source
Successful
data PartialContent Source
data AlreadyReported Source
Redirection
data MultipleChoices Source
data MovedPermanently Source
data TemporaryRedirect Source
Client Error
data PaymentRequired Source
data MethodNotAllowed Source
data RequestTimeout Source
data LengthRequired Source
data PreconditionFailed Source
data RequestURITooLarge Source
data ExpectationFailed Source
data FailedDependency Source
data UpgradeRequired Source
Server Error
data NotImplemented Source
data GatewayTimeout Source