module Network.Wai.Middleware.HealthCheckEndpoint (
healthCheck,
voidEndpoint,
)
where
import Data.ByteString (ByteString)
import Network.HTTP.Types (status200)
import Network.Wai
healthCheck :: Middleware
healthCheck :: Middleware
healthCheck = ByteString -> Middleware
voidEndpoint ByteString
"/_healthz"
voidEndpoint :: ByteString -> Middleware
voidEndpoint :: ByteString -> Middleware
voidEndpoint ByteString
endpointPath Application
router Request
request Response -> IO ResponseReceived
respond =
if Request -> ByteString
rawPathInfo Request
request ByteString -> ByteString -> Bool
forall a. Eq a => a -> a -> Bool
== ByteString
endpointPath
then Response -> IO ResponseReceived
respond (Response -> IO ResponseReceived)
-> Response -> IO ResponseReceived
forall a b. (a -> b) -> a -> b
$ Status -> ResponseHeaders -> ByteString -> Response
responseLBS Status
status200 ResponseHeaders
forall a. Monoid a => a
mempty ByteString
"-"
else Application
router Request
request Response -> IO ResponseReceived
respond