Module

Node.HTTP

Package
purescript-node-http
Repository
purescript-node/purescript-node-http

This module defines low-level bindings to the Node HTTP module.

#Server Source

data Server :: Type

The type of a HTTP server object

#Request Source

data Request :: Type

A HTTP request object

#Response Source

data Response :: Type

A HTTP response object

#HTTP Source

data HTTP :: Effect

The effect associated with using the HTTP module.

#createServer Source

createServer :: forall eff. (Request -> Response -> Eff (http :: HTTP | eff) Unit) -> Eff (http :: HTTP | eff) Server

Create a HTTP server, given a function to be executed when a request is received.

#listen Source

listen :: forall eff. Server -> ListenOptions -> Eff (http :: HTTP | eff) Unit -> Eff (http :: HTTP | eff) Unit

Listen on a port in order to start accepting HTTP requests. The specified callback will be run when setup is complete.

#close Source

close :: forall eff. Server -> Eff (http :: HTTP | eff) Unit -> Eff (http :: HTTP | eff) Unit

Close a listening HTTP server. The specified callback will be run the server closing is complete.

#ListenOptions Source

type ListenOptions = { backlog :: Maybe Int, hostname :: String, port :: Int }

Options to be supplied to listen. See the Node API for detailed information about these.

#listenSocket Source

listenSocket :: forall eff. Server -> String -> Eff (http :: HTTP | eff) Unit -> Eff (http :: HTTP | eff) Unit

Listen on a unix socket. The specified callback will be run when setup is complete.

#httpVersion Source

httpVersion :: Request -> String

Get the request HTTP version

#requestHeaders Source

requestHeaders :: Request -> StrMap String

Get the request headers as a hash

#requestMethod Source

requestMethod :: Request -> String

Get the request method (GET, POST, etc.)

#requestURL Source

requestURL :: Request -> String

Get the request URL

#requestAsStream Source

requestAsStream :: forall eff. Request -> Readable () (http :: HTTP | eff)

Coerce the request object into a readable stream.

#setHeader Source

setHeader :: forall eff. Response -> String -> String -> Eff (http :: HTTP | eff) Unit

Set a header with a single value.

#setHeaders Source

setHeaders :: forall eff. Response -> String -> Array String -> Eff (http :: HTTP | eff) Unit

Set a header with multiple values.

#setStatusCode Source

setStatusCode :: forall eff. Response -> Int -> Eff (http :: HTTP | eff) Unit

Set the status code.

#setStatusMessage Source

setStatusMessage :: forall eff. Response -> String -> Eff (http :: HTTP | eff) Unit

Set the status message.

#responseAsStream Source

responseAsStream :: forall eff. Response -> Writable () (http :: HTTP | eff)

Coerce the response object into a writable stream.