Module

HTTPure

Package
purescript-httpure
Repository
cprussin/purescript-httpure

Re-exports from HTTPure.Headers

#Headers Source

newtype Headers

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

Instances

  • Newtype Headers _
  • Lookup Headers String String

    Given a string, return a Maybe containing the value of the matching header, if there is any.

  • Show Headers

    Allow a Headers to be represented as a string. This string is formatted in HTTP headers format.

  • Eq Headers

    Compare two Headers objects by comparing the underlying Objects.

  • Semigroup Headers

    Allow one Headers objects to be appended to another.

#headers Source

headers :: Array (Tuple String String) -> Headers

Convert an Array of Tuples of 2 Strings to a Headers object.

#header Source

header :: String -> String -> Headers

Create a singleton header from a key-value pair.

#empty Source

empty :: Headers

Return a Headers containing nothing.

Re-exports from HTTPure.Lookup

#lookup Source

lookup :: forall r k c. Lookup c k r => c -> k -> Maybe r

Given some type and a key on that type, extract some value that corresponds to that key.

#has Source

has :: forall c k r. Lookup (c r) k r => c r -> k -> Boolean

This simple helper works on any Lookup instance, where the container set has a single type variable, and returns a Boolean indicating if the given key matches any value in the given container.

#at Source

at :: forall c k r. Monoid r => Lookup c k r => c -> k -> r

This simple helper works on any Lookup instance where the return type is a Monoid, and is the same as lookup except that it returns a t instead of a Maybe t. If lookup would return Nothing, then at returns mempty.

#(!@) Source

Operator alias for HTTPure.Lookup.at (left-associative / precedence 8)

Expose at as the infix operator !@

#(!?) Source

Operator alias for HTTPure.Lookup.has (left-associative / precedence 8)

Expose has as the infix operator !?

#(!!) Source

Operator alias for HTTPure.Lookup.lookup (left-associative / precedence 8)

!! is inspired by !! in Data.Array, but note that it differs from !! in Data.Array in that you can use !! for any other instance of Lookup.

Re-exports from HTTPure.Method

#Method Source

data Method

These are the HTTP methods that HTTPure understands.

Constructors

Instances

Re-exports from HTTPure.Path

#Path Source

type Path = Array String

The Path type is just sugar for an Array of String segments that are sent in a request and indicates the path of the resource being requested. Note that this type has an implementation of Lookup for Int keys defined by lookupArray in Lookup.purs because lookupArray is defined for any Array of Monoids. So you can do something like path !! 2 to get the path segment at index 2.

Re-exports from HTTPure.Query

#Query Source

type Query = Object String

The Query type is a Object of Strings, with one entry per query parameter in the request. For any query parameters that don't have values (/some/path?query or /some/path?query=), the value in the Object for that parameter will be the an empty string. Note that this type has an implementation of Lookup for String keys defined by lookupObject in Lookup.purs because lookupObject is defined for any Object of Monoids. So you can do something like query !! "foo" to get the value of the query parameter "foo".

Re-exports from HTTPure.Request

#Request Source

type Request = { body :: String, headers :: Headers, httpVersion :: Version, method :: Method, path :: Path, query :: Query }

The Request type is a Record type that includes fields for accessing the different parts of the HTTP request.

#fullPath Source

fullPath :: Request -> String

Return the full resolved path, including query parameters. This may not match the requested path--for instance, if there are empty path segments in the request--but it is equivalent.

Re-exports from HTTPure.Response

#ResponseM Source

type ResponseM = Aff 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

type Response = { headers :: Headers, status :: Status, writeBody :: Response -> Aff Unit }

A Response is a status code, headers, and a body.

#variantAlsoNegotiates' Source

#variantAlsoNegotiates Source

#useProxy' Source

useProxy' :: forall b. Body b => Headers -> b -> ResponseM

305 with headers

#useProxy Source

useProxy :: forall b. Body b => b -> ResponseM

305

#upgradeRequired' Source

upgradeRequired' :: Headers -> ResponseM

426 with headers

#upgradeRequired Source

#unsupportedMediaType' Source

unsupportedMediaType' :: Headers -> ResponseM

415 with headers

#unsupportedMediaType Source

#unprocessableEntity' Source

unprocessableEntity' :: Headers -> ResponseM

422 with headers

#unprocessableEntity Source

#unavailableForLegalReasons' Source

#unavailableForLegalReasons Source

#unauthorized' Source

unauthorized' :: Headers -> ResponseM

401 with headers

#unauthorized Source

#uRITooLong' Source

uRITooLong' :: Headers -> ResponseM

414 with headers

#uRITooLong Source

#tooManyRequests' Source

tooManyRequests' :: Headers -> ResponseM

429 with headers

#tooManyRequests Source

#temporaryRedirect' Source

temporaryRedirect' :: forall b. Body b => Headers -> b -> ResponseM

307 with headers

#temporaryRedirect Source

temporaryRedirect :: forall b. Body b => b -> ResponseM

307

#switchingProtocols' Source

switchingProtocols' :: Headers -> ResponseM

101 with headers

#switchingProtocols Source

#serviceUnavailable' Source

serviceUnavailable' :: Headers -> ResponseM

503 with headers

#serviceUnavailable Source

#seeOther' Source

seeOther' :: forall b. Body b => Headers -> b -> ResponseM

303 with headers

#seeOther Source

seeOther :: forall b. Body b => b -> ResponseM

303

#response' Source

response' :: forall b. Body b => Status -> Headers -> b -> ResponseM

The same as response but with headers.

#response Source

response :: forall b. Body b => Status -> b -> ResponseM

For custom response statuses or providing a body for response codes that don't typically send one.

#resetContent' Source

resetContent' :: Headers -> ResponseM

205 with headers

#resetContent Source

#requestTimeout' Source

requestTimeout' :: Headers -> ResponseM

408 with headers

#requestTimeout Source

#requestHeaderFieldsTooLarge' Source

#requestHeaderFieldsTooLarge Source

#rangeNotSatisfiable' Source

rangeNotSatisfiable' :: Headers -> ResponseM

416 with headers

#rangeNotSatisfiable Source

#proxyAuthenticationRequired' Source

#proxyAuthenticationRequired Source

#processing' Source

processing' :: Headers -> ResponseM

102 with headers

#processing Source

#preconditionRequired' Source

preconditionRequired' :: Headers -> ResponseM

428 with headers

#preconditionRequired Source

#preconditionFailed' Source

preconditionFailed' :: Headers -> ResponseM

412 with headers

#preconditionFailed Source

#permanentRedirect' Source

permanentRedirect' :: forall b. Body b => Headers -> b -> ResponseM

308 with headers

#permanentRedirect Source

permanentRedirect :: forall b. Body b => b -> ResponseM

308

#paymentRequired' Source

paymentRequired' :: Headers -> ResponseM

402 with headers

#paymentRequired Source

#payloadTooLarge' Source

payloadTooLarge' :: Headers -> ResponseM

413 with headers

#payloadTooLarge Source

#partialContent' Source

partialContent' :: forall b. Body b => Headers -> b -> ResponseM

206 with headers

#partialContent Source

partialContent :: forall b. Body b => b -> ResponseM

206

#ok' Source

ok' :: forall b. Body b => Headers -> b -> ResponseM

200 with headers

#ok Source

ok :: forall b. Body b => b -> ResponseM

200

#notModified' Source

notModified' :: Headers -> ResponseM

304 with headers

#notModified Source

#notImplemented' Source

notImplemented' :: Headers -> ResponseM

501 with headers

#notImplemented Source

#notFound' Source

notFound' :: Headers -> ResponseM

404 with headers

#notFound Source

#notExtended' Source

notExtended' :: Headers -> ResponseM

510 with headers

#notExtended Source

#notAcceptable' Source

notAcceptable' :: Headers -> ResponseM

406 with headers

#notAcceptable Source

#nonAuthoritativeInformation' Source

nonAuthoritativeInformation' :: forall b. Body b => Headers -> b -> ResponseM

203 with headers

#nonAuthoritativeInformation Source

nonAuthoritativeInformation :: forall b. Body b => b -> ResponseM

203

#noContent' Source

noContent' :: Headers -> ResponseM

204 with headers

#noContent Source

#networkAuthenticationRequired' Source

#networkAuthenticationRequired Source

#multipleChoices' Source

multipleChoices' :: forall b. Body b => Headers -> b -> ResponseM

300 with headers

#multipleChoices Source

multipleChoices :: forall b. Body b => b -> ResponseM

300

#multiStatus' Source

multiStatus' :: forall b. Body b => Headers -> b -> ResponseM

207 with headers

#multiStatus Source

multiStatus :: forall b. Body b => b -> ResponseM

207

#movedPermanently' Source

movedPermanently' :: forall b. Body b => Headers -> b -> ResponseM

301 with headers

#movedPermanently Source

movedPermanently :: forall b. Body b => b -> ResponseM

301

#misdirectedRequest' Source

misdirectedRequest' :: Headers -> ResponseM

421 with headers

#misdirectedRequest Source

#methodNotAllowed' Source

methodNotAllowed' :: Headers -> ResponseM

405 with headers

#methodNotAllowed Source

#loopDetected' Source

loopDetected' :: Headers -> ResponseM

508 with headers

#loopDetected Source

#locked' Source

locked' :: Headers -> ResponseM

423 with headers

#locked Source

#lengthRequired' Source

lengthRequired' :: Headers -> ResponseM

411 with headers

#lengthRequired Source

#internalServerError' Source

internalServerError' :: forall b. Body b => Headers -> b -> ResponseM

500 with headers

#internalServerError Source

internalServerError :: forall b. Body b => b -> ResponseM

500

#insufficientStorage' Source

insufficientStorage' :: Headers -> ResponseM

507 with headers

#insufficientStorage Source

#imATeapot' Source

imATeapot' :: Headers -> ResponseM

418 with headers

#imATeapot Source

#iMUsed' Source

iMUsed' :: forall b. Body b => Headers -> b -> ResponseM

226 with headers

#iMUsed Source

iMUsed :: forall b. Body b => b -> ResponseM

226

#hTTPVersionNotSupported' Source

#hTTPVersionNotSupported Source

#gone' Source

gone' :: Headers -> ResponseM

410 with headers

#gatewayTimeout' Source

gatewayTimeout' :: Headers -> ResponseM

504 with headers

#gatewayTimeout Source

#found' Source

found' :: forall b. Body b => Headers -> b -> ResponseM

302 with headers

#found Source

found :: forall b. Body b => b -> ResponseM

302

#forbidden' Source

forbidden' :: Headers -> ResponseM

403 with headers

#forbidden Source

#failedDependency' Source

failedDependency' :: Headers -> ResponseM

424 with headers

#failedDependency Source

#expectationFailed' Source

expectationFailed' :: Headers -> ResponseM

417 with headers

#expectationFailed Source

#emptyResponse' Source

emptyResponse' :: Status -> Headers -> ResponseM

The same as emptyResponse but with headers.

#emptyResponse Source

emptyResponse :: Status -> ResponseM

The same as response but without a body.

#created' Source

created' :: Headers -> ResponseM

201 with headers

#created Source

#continue' Source

continue' :: Headers -> ResponseM

100 with headers

#continue Source

#conflict' Source

conflict' :: forall b. Body b => Headers -> b -> ResponseM

409 with headers

#conflict Source

conflict :: forall b. Body b => b -> ResponseM

409

#badRequest' Source

badRequest' :: forall b. Body b => Headers -> b -> ResponseM

400 with headers

#badRequest Source

badRequest :: forall b. Body b => b -> ResponseM

400

#badGateway' Source

badGateway' :: Headers -> ResponseM

502 with headers

#badGateway Source

#alreadyReported' Source

alreadyReported' :: Headers -> ResponseM

208 with headers

#alreadyReported Source

#accepted' Source

accepted' :: Headers -> ResponseM

202 with headers

#accepted Source

Re-exports from HTTPure.Server

#ServerM Source

type ServerM = Effect (Effect Unit -> Effect Unit)

The ServerM is just an Effect containing a callback to close the server. This type is the return type of the HTTPure serve and related methods.

#serveSecure' Source

serveSecure' :: Options SSLOptions -> ListenOptions -> (Request -> ResponseM) -> Effect Unit -> ServerM

Given a Options HTTPS.SSLOptions object and a HTTP.ListenOptions object, a function mapping Request to ResponseM, and a ServerM containing effects to run on boot, creates and runs a HTTPure server with SSL.

#serveSecure Source

serveSecure :: Int -> String -> String -> (Request -> ResponseM) -> Effect Unit -> ServerM

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' :: ListenOptions -> (Request -> ResponseM) -> Effect Unit -> ServerM

Given a ListenOptions object, a function mapping Request to ResponseM, and a ServerM containing effects to run on boot, creates and runs a HTTPure server without SSL.

#serve Source

serve :: Int -> (Request -> ResponseM) -> Effect Unit -> ServerM

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 a ServerM containing effects to run after the server has booted (usually logging). Returns an ServerM containing the server's effects.

Re-exports from HTTPure.Status

#Status Source

type Status = Int

The Status type enumerates all valid HTTP response status codes.