Lucu-1.0: Embedded HTTP Server

Network.HTTP.Lucu.Response.StatusCode

Contents

Description

Definition of HTTP status codes.

Synopsis

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.

Methods

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.

Instances

Eq SomeStatusCode

Equivalence of StatusCodes. Two StatusCodes α and β are said to be equivalent iff numericCode α == numericCode β.

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)
   instance StatusCode OK where
     numericCode   _ = 200
     textualStatus _ = cs ("200 OK"  Ascii)

data BadRequest = BadRequest deriving (Eq, Show)
   instance StatusCode BadRequest where
     numericCode   _ = 400
     textualStatus _ = cs ("400 Bad Request"  Ascii)

data MethodNotAllowed = MethodNotAllowed deriving (Eq, Show)
   instance StatusCode MethodNotAllowed where
     numericCode   _ = 405
     textualStatus _ = cs ("405 Method Not Allowed"  Ascii)

Status codes

Informational

Successful

data OK Source

Constructors

OK 

Instances

data Created Source

Constructors

Created 

data IMUsed Source

Constructors

IMUsed 

Redirection

data Found Source

Constructors

Found 

Client Error

data Gone Source

Constructors

Gone 

data Locked Source

Constructors

Locked 

Server Error