{-# LANGUAGE OverloadedStrings #-} module Network.Wai.Middleware.Health (health) where import Network.HTTP.Types (methodGet, status200) import Network.HTTP.Types.Header (hContentType) import Network.Wai health :: Middleware health :: Middleware health Application app Request req Response -> IO ResponseReceived sendResponse = case Request -> ByteString rawPathInfo Request req of ByteString "/health" -> if Bool getReq then IO ResponseReceived healthy else IO ResponseReceived next ByteString _ -> IO ResponseReceived next where next :: IO ResponseReceived next = Application app Request req Response -> IO ResponseReceived sendResponse getReq :: Bool getReq = Request -> ByteString requestMethod Request req ByteString -> ByteString -> Bool forall a. Eq a => a -> a -> Bool == ByteString methodGet healthy :: IO ResponseReceived healthy = Response -> IO ResponseReceived sendResponse (Response -> IO ResponseReceived) -> Response -> IO ResponseReceived forall a b. (a -> b) -> a -> b $ Status -> ResponseHeaders -> ByteString -> Response responseLBS Status status200 ResponseHeaders headers ByteString "Healthy" headers :: ResponseHeaders headers = [(HeaderName hContentType, ByteString "text/plain")]