Hoogle Search

Within LTS Haskell 24.38 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. setApacheRequestFilter :: (Request -> Response -> Bool) -> ApacheSettings -> ApacheSettings

    wai-extra Network.Wai.Middleware.RequestLogger

    Function that allows you to filter which requests are logged, based on the request and response Default: log all requests

  2. requestToJSON :: Request -> [ByteString] -> Maybe NominalDiffTime -> Value

    wai-extra Network.Wai.Middleware.RequestLogger.JSON

    Get the JSON representation for a request This representation is identical to that used in formatAsJSON for the request. It includes:

    • method
    • path
    • queryString
    • size The size of the body, as defined in the request. This may differ from the size of the data passed in the second argument.
    • body The body, concatenated directly from the chunks passed in
    • remoteHost
    • httpVersion
    • headers
    If a Just duration is passed in, then additionally the JSON includes:
    • durationMs The duration, formatted in milliseconds, to 2 decimal places
    This representation is not an API, and may change at any time (within reason) without a major version bump.

  3. module Network.Wai.Middleware.RequestSizeLimit

    The functions in this module allow you to limit the total size of incoming request bodies. Limiting incoming request body size helps protect your server against denial-of-service (DOS) attacks, in which an attacker sends huge bodies to your server.

  4. data RequestSizeLimitSettings

    wai-extra Network.Wai.Middleware.RequestSizeLimit

    Settings to configure requestSizeLimitMiddleware. This type (but not the constructor, or record fields) is exported from Network.Wai.Middleware.RequestSizeLimit. Since the constructor isn't exported, create a default value with defaultRequestSizeLimitSettings first, then set the values using setMaxLengthForRequest and setOnLengthExceeded (See the examples below). If you need to access the constructor directly, it's exported from Network.Wai.Middleware.RequestSizeLimit.Internal.

    Examples

    Conditionally setting the limit based on the request
    {-# LANGUAGE OverloadedStrings #-}
    import Network.Wai
    import Network.Wai.Middleware.RequestSizeLimit
    
    let megabyte = 1024 * 1024
    let sizeForReq req = if pathInfo req == ["upload", "image"] then pure $ Just $ megabyte * 20 else pure $ Just $ megabyte * 2
    let finalSettings = setMaxLengthForRequest sizeForReq defaultRequestSizeLimitSettings
    
    JSON response
    {-# LANGUAGE OverloadedStrings #-}
    import Network.Wai
    import Network.Wai.Middleware.RequestSizeLimit
    import Network.HTTP.Types.Status (requestEntityTooLarge413)
    import Data.Aeson
    import Data.Text (Text)
    
    let jsonResponse = \_maxLen _app _req sendResponse -> sendResponse $ responseLBS requestEntityTooLarge413 [("Content-Type", "application/json")] (encode $ object ["error" .= ("request size too large" :: Text)])
    let finalSettings = setOnLengthExceeded jsonResponse defaultRequestSizeLimitSettings
    

  5. defaultRequestSizeLimitSettings :: RequestSizeLimitSettings

    wai-extra Network.Wai.Middleware.RequestSizeLimit

    Create a RequestSizeLimitSettings with these settings:

    • 2MB size limit for all requests
    • When the limit is exceeded, return a plain text response describing the error, with a 413 status code.

  6. requestSizeLimitMiddleware :: RequestSizeLimitSettings -> Middleware

    wai-extra Network.Wai.Middleware.RequestSizeLimit

    Middleware to limit request bodies to a certain size. This uses requestSizeCheck under the hood; see that function for details.

  7. setMaxLengthForRequest :: (Request -> IO (Maybe Word64)) -> RequestSizeLimitSettings -> RequestSizeLimitSettings

    wai-extra Network.Wai.Middleware.RequestSizeLimit

    Function to determine the maximum request size in bytes for the request. Return Nothing for no limit.

  8. data RequestSizeLimitSettings

    wai-extra Network.Wai.Middleware.RequestSizeLimit.Internal

    Settings to configure requestSizeLimitMiddleware. This type (but not the constructor, or record fields) is exported from Network.Wai.Middleware.RequestSizeLimit. Since the constructor isn't exported, create a default value with defaultRequestSizeLimitSettings first, then set the values using setMaxLengthForRequest and setOnLengthExceeded (See the examples below). If you need to access the constructor directly, it's exported from Network.Wai.Middleware.RequestSizeLimit.Internal.

    Examples

    Conditionally setting the limit based on the request
    {-# LANGUAGE OverloadedStrings #-}
    import Network.Wai
    import Network.Wai.Middleware.RequestSizeLimit
    
    let megabyte = 1024 * 1024
    let sizeForReq req = if pathInfo req == ["upload", "image"] then pure $ Just $ megabyte * 20 else pure $ Just $ megabyte * 2
    let finalSettings = setMaxLengthForRequest sizeForReq defaultRequestSizeLimitSettings
    
    JSON response
    {-# LANGUAGE OverloadedStrings #-}
    import Network.Wai
    import Network.Wai.Middleware.RequestSizeLimit
    import Network.HTTP.Types.Status (requestEntityTooLarge413)
    import Data.Aeson
    import Data.Text (Text)
    
    let jsonResponse = \_maxLen _app _req sendResponse -> sendResponse $ responseLBS requestEntityTooLarge413 [("Content-Type", "application/json")] (encode $ object ["error" .= ("request size too large" :: Text)])
    let finalSettings = setOnLengthExceeded jsonResponse defaultRequestSizeLimitSettings
    

  9. RequestSizeLimitSettings :: (Request -> IO (Maybe Word64)) -> (Word64 -> Middleware) -> RequestSizeLimitSettings

    wai-extra Network.Wai.Middleware.RequestSizeLimit.Internal

    No documentation available.

  10. maxLengthForRequest :: RequestSizeLimitSettings -> Request -> IO (Maybe Word64)

    wai-extra Network.Wai.Middleware.RequestSizeLimit.Internal

    Function to determine the maximum request size in bytes for the request. Return Nothing for no limit. Since 3.1.1

Page 234 of many | Previous | Next