Module

HTTPure.Middleware

#LogLifecycle

type LogLifecycle a = { after :: Request -> Response -> a -> Aff String, before :: Request -> Aff a }

The lifecycle functions around logging.

Used to prepare metadata for the logs.

#LogTime

type LogTime = { duration :: Milliseconds, start :: DateTime, stop :: DateTime }

A helper that encapsulates the different information around request time.

#Middleware

type Middleware = (Request -> ResponseM) -> Request -> ResponseM

A helper for cleaning up type signatures.

#combinedLogFormat

combinedLogFormat :: Middleware

A middleware that logs requests in the Combined Log Format.

#commonLogFormat

commonLogFormat :: Middleware

A middleware that logs requests in the Common Log Format.

#developmentLogFormat

developmentLogFormat :: Middleware

A middleware that logs request in an unstandardized development format. The logs are more verbose, colorful, and a bit easier to read.

#log

log :: forall a. LogLifecycle a -> Middleware

Logs the request given the lifecycle functions.

#logWithTime

logWithTime :: (LogTime -> Request -> Response -> Aff String) -> Middleware

Helper for logging when all you need is the time metadata.

#timeout

timeout :: forall a. Duration a => a -> Middleware

A middleware that prevents requests from running for too long.

If a request takes longer than the duration specified, it returns a 500 status code

Modules