Copyright | Michael Snoyman |
---|---|
License | BSD3 |
Maintainer | Michael Snoyman <michael@snoyman.com> |
Stability | Unstable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Dynamically choose between Middlewares
It's useful when you want some Middleware
s applied selectively.
Example: do not log health check calls:
import Network.Wai import Network.Wai.Middleware.HealthCheckEndpoint import Network.Wai.Middleware.RequestLogger app' :: Application app' = selectMiddleware (selectMiddlewareExceptRawPathInfo "/_healthz" logStdout) $ healthCheck app
Since: 3.1.10
Synopsis
- newtype MiddlewareSelection = MiddlewareSelection {}
- selectMiddleware :: MiddlewareSelection -> Middleware
- selectMiddlewareOn :: (Request -> Bool) -> Middleware -> MiddlewareSelection
- selectMiddlewareOnRawPathInfo :: ByteString -> Middleware -> MiddlewareSelection
- selectMiddlewareExceptRawPathInfo :: ByteString -> Middleware -> MiddlewareSelection
- passthroughMiddleware :: Middleware
Middleware selection
newtype MiddlewareSelection Source #
Relevant Middleware for a given Request
.
Instances
selectMiddleware :: MiddlewareSelection -> Middleware Source #
Create the Middleware
dynamically applying MiddlewareSelection
.
Helpers
selectMiddlewareOn :: (Request -> Bool) -> Middleware -> MiddlewareSelection Source #
Use the Middleware
when the predicate holds.
selectMiddlewareOnRawPathInfo :: ByteString -> Middleware -> MiddlewareSelection Source #
Use the Middleware
for the given rawPathInfo
.
selectMiddlewareExceptRawPathInfo :: ByteString -> Middleware -> MiddlewareSelection Source #
Use the Middleware
for all rawPathInfo
except then given one.