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

  • 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 c k r. 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 r k c. 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 r k c. 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.Request

#Request Source

type Request = { body :: Body, headers :: Headers, 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.

#variantAlsoNegotiates' Source

#variantAlsoNegotiates Source

#useProxy' Source

useProxy' :: Headers -> Body -> ResponseM

305 with headers

#useProxy Source

#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' :: Headers -> Body -> ResponseM

307 with headers

#temporaryRedirect Source

#switchingProtocols' Source

switchingProtocols' :: Headers -> ResponseM

101 with headers

#switchingProtocols Source

#serviceUnavailable' Source

serviceUnavailable' :: Headers -> ResponseM

503 with headers

#serviceUnavailable Source

#seeOther' Source

seeOther' :: Headers -> Body -> ResponseM

303 with headers

#seeOther Source

#response' Source

response' :: Status -> Headers -> Body -> ResponseM

The same as response but with headers.

#response Source

response :: Status -> Body -> 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' :: Headers -> Body -> ResponseM

308 with headers

#permanentRedirect Source

#paymentRequired' Source

paymentRequired' :: Headers -> ResponseM

402 with headers

#paymentRequired Source

#payloadTooLarge' Source

payloadTooLarge' :: Headers -> ResponseM

413 with headers

#payloadTooLarge Source

#partialContent' Source

partialContent' :: Headers -> Body -> ResponseM

206 with headers

#partialContent Source

#ok' Source

ok' :: Headers -> Body -> ResponseM

200 with headers

#ok Source

ok :: Body -> 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 Source

#noContent' Source

noContent' :: Headers -> ResponseM

204 with headers

#noContent Source

#networkAuthenticationRequired' Source

#networkAuthenticationRequired Source

#multipleChoices' Source

multipleChoices' :: Headers -> Body -> ResponseM

300 with headers

#multipleChoices Source

#multiStatus' Source

multiStatus' :: Headers -> Body -> ResponseM

207 with headers

#multiStatus Source

#movedPermanently' Source

movedPermanently' :: Headers -> Body -> ResponseM

301 with headers

#movedPermanently Source

#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' :: Headers -> Body -> ResponseM

500 with headers

#internalServerError Source

#insufficientStorage' Source

insufficientStorage' :: Headers -> ResponseM

507 with headers

#insufficientStorage Source

#imATeapot' Source

imATeapot' :: Headers -> ResponseM

418 with headers

#imATeapot Source

#iMUsed' Source

iMUsed' :: Headers -> Body -> ResponseM

226 with headers

#iMUsed Source

#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' :: Headers -> Body -> ResponseM

302 with headers

#found Source

found :: Body -> 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' :: Headers -> Body -> ResponseM

409 with headers

#conflict Source

#badRequest' Source

badRequest' :: Headers -> Body -> ResponseM

400 with headers

#badRequest Source

#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 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.

#serveSecure' Source

serveSecure' :: Options SSLOptions -> ListenOptions -> (Request -> ResponseM) -> ServerM -> 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) -> ServerM -> 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) -> ServerM -> 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) -> ServerM -> 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.