Copyright | (c) Eduardo Trujillo, 2016 |
---|---|
License | Apache |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
A collection of middleware useful for static websites.
- data MiddlewareStack = MiddlewareStack [Middleware]
- (<#>) :: MiddlewareStack -> Middleware -> MiddlewareStack
- flatten :: MiddlewareStack -> Middleware
- wrap :: MiddlewareStack -> Application -> Application
- loggerMiddleware :: Middleware
- forceSSLMiddleware :: Middleware
- gzipMiddleware :: Middleware
- domainMiddleware :: Domain -> Middleware
- securityHeadersMiddleware :: Middleware
- stsHeadersMiddleware :: Middleware
- cspHeadersMiddleware :: [Directive] -> Middleware
- deindexifyMiddleware :: Middleware
Middleware Stacks
data MiddlewareStack Source #
A middleware stack is a simple container of Wai middleware. The top of the stack is considered to be the outermost layer of middleware while the bottom of the stack is the innermost layer of middleware.
The stack is a Monoid
, so it can be combined with other stacks using
<>
, and an empty one can be obtained using mempty
.
MiddlewareStack [Middleware] | The constructor takes a list of middleware, where the left-most item in the list will end up at the top of the stack, and the right-most at the bottom. |
(<#>) :: MiddlewareStack -> Middleware -> MiddlewareStack infixl 5 Source #
A combinator for adding a middleware to the bottom of a stack.
flatten :: MiddlewareStack -> Middleware Source #
Combines the entire stack into a single middleware.
wrap :: MiddlewareStack -> Application -> Application Source #
Wraps a WAI application in the stack. (Alias of flatten
)
Middleware
loggerMiddleware :: Middleware Source #
Logger middleware.
forceSSLMiddleware :: Middleware Source #
Middleware for forcing requests to be done through SSL.
gzipMiddleware :: Middleware Source #
Gzip compression middleware.
domainMiddleware :: Domain -> Middleware Source #
Domain redirection middleware.
When the site is live, we want to redirect users to the right domain name regarles of whether they arrive from a www. domain, the server's IP address or a spoof domain which is pointing to this server.
securityHeadersMiddleware :: Middleware Source #
Common security headers middleware.
stsHeadersMiddleware :: Middleware Source #
Strict Transport Security middleware.
cspHeadersMiddleware :: [Directive] -> Middleware Source #
Content Security Policy middleware.
Here we add the CSP header which includes the policies for this blog.
deindexifyMiddleware :: Middleware Source #
De-indexify middleware.
Redirects any path ending in `/index.html` to just /
.