Something went wrong. Try again.
A Haskell Webserver Template
Something went wrong. Try again.
798 B · 34 lines
Haskell
at main
1234567891011121314151617181920212223242526272829303132333435module Webserver.Data.BodyError ( BodyError (..), defaultMaxBodySize,)where
----------------------------------------------------------------------------------------------------
kilobytes :: Int -> Intkilobytes = (*) 1000
kibibytes :: Int -> Intkibibytes = (*) 1024
megabytes :: Int -> Intmegabytes = (*) 1000000
mebibytes :: Int -> Intmebibytes = (*) 1048576
-- | Maximum request body size in bytes (1 MiB)defaultMaxBodySize :: IntdefaultMaxBodySize = mebibytes 1
-- | Errors that can occur when reading a request bodydata 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