Module

HTTPure

Package
purescript-httpure
Repository
cprussin/purescript-httpure

Re-exports from HTTPure.Headers

#Headers Source

type Headers = StrMap String

The Headers type is just sugar for a StrMap of Strings that represents the set of headers sent or received in an HTTP request or response.

#lookup Source

lookup :: Headers -> String -> String

Return the value of the given header.

Re-exports from HTTPure.Request

#Request Source

data Request

A Request is a method along with headers, a path, and sometimes a body.

Constructors

Instances

  • Show Request

    When using show on a Request, print the method and the path.

Re-exports from HTTPure.Response

#ResponseM Source

type ResponseM e = HTTPureM e Response

The ResponseM type simply conveniently wraps up an HTTPure monad that returns a response. This type is the return type of all router/route methods.

#Response Source

data Response

A response is a status and headers, and for some statuses, a body. You can use the data constructor Response to send non-standard status codes.

Constructors

Re-exports from HTTPure.Server

#ServerM Source

type ServerM e = HTTPureM e Unit

The ServerM type simply conveniently wraps up an HTTPure monad that returns a Unit. This type is the return type of the HTTPure serve and related methods.

#SecureServerM Source

type SecureServerM e = ServerM (fs :: FS | e)

The SecureServerM type is the same as the ServerM type, but it includes effects for working with the filesystem (to load the key and certificate).

#serve' Source

serve' :: forall e. Int -> String -> String -> (Request -> ResponseM (fs :: FS | e)) -> SecureServerM e -> SecureServerM e

Create and start an SSL server. This method is the same as serve, but takes additional SSL arguments. The arguments in order are:

  1. A port number
  2. A path to a cert file
  3. A path to a private key file
  4. A handler method which maps Request to ResponseM
  5. A callback to call when the server is up

#serve Source

serve :: forall e. Int -> (Request -> ResponseM e) -> ServerM e -> ServerM e

Create and start a server. This is the main entry point for HTTPure. Takes a port number on which to listen, a function mapping Request to ResponseM, and an HTTPureM containing effects to run after the server has booted (usually logging). Returns an HTTPureM containing the server's effects.