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

#createServer Source

createServer :: (Request -> Response -> Effect Unit) -> Effect Server

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

#listen Source

listen :: Server -> ListenOptions -> Effect Unit -> Effect 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 :: Server -> Effect Unit -> Effect 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 :: Server -> String -> Effect Unit -> Effect 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 -> Object 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 :: Request -> Readable ()

Coerce the request object into a readable stream.

#setHeader Source

setHeader :: Response -> String -> String -> Effect Unit

Set a header with a single value.

#setHeaders Source

setHeaders :: Response -> String -> Array String -> Effect Unit

Set a header with multiple values.

#setStatusCode Source

setStatusCode :: Response -> Int -> Effect Unit

Set the status code.

#setStatusMessage Source

setStatusMessage :: Response -> String -> Effect Unit

Set the status message.

#responseAsStream Source

responseAsStream :: Response -> Writable ()

Coerce the response object into a writable stream.