module Webserver.Data.BodyError ( BodyError (..), defaultMaxBodySize, ) where ---------------------------------------------------------------------------------------------------- kilobytes :: Int -> Int kilobytes = (*) 1000 kibibytes :: Int -> Int kibibytes = (*) 1024 megabytes :: Int -> Int megabytes = (*) 1000000 mebibytes :: Int -> Int mebibytes = (*) 1048576 -- | Maximum request body size in bytes (1 MiB) defaultMaxBodySize :: Int defaultMaxBodySize = mebibytes 1 -- | Errors that can occur when reading a request body data BodyError = -- | Content-Type header is missing or not application/json UnsupportedContentType | -- | Accumulated body bytes exceed the maximum size BodyTooLarge | -- | JSON decoding failed DecodeFailed deriving instance Show BodyError