{-# LANGUAGE OverloadedStrings #-} module Network.Wai.Middleware.Info (info) where import qualified Data.ByteString.Lazy as LB import Network.HTTP.Types (methodGet, status200) import Network.HTTP.Types.Header (hContentType) import Network.Wai info :: LB.ByteString -> Middleware info :: ByteString -> Middleware info ByteString payload Application app Request req Response -> IO ResponseReceived sendResponse = case Request -> ByteString rawPathInfo Request req of ByteString "/info" -> if Bool getReq then IO ResponseReceived returnInfo 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 returnInfo :: IO ResponseReceived returnInfo = 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 payload headers :: ResponseHeaders headers = [(HeaderName hContentType, ByteString "application/json")]