Ketchup-0.4.1: A super small web framework for those who don't like big and fancy codebases

Safe HaskellNone
LanguageHaskell98

Ketchup.Utils

Synopsis

Documentation

breakBS :: ByteString -> ByteString -> (ByteString, ByteString) Source

ByteString breakSubstring wrapper that drops delimiters

fallback :: Maybe a -> a -> a Source

Maybe a -> a with fallback (if Nothing)

parseBody :: ByteString -> [(ByteString, ByteString)] Source

Parse a URL-encoded Request

sendBadRequest :: Socket -> IO () Source

Send 400 Bad Request error

sendNotFound :: Socket -> IO () Source

Send 404 Not Found error

sendReply Source

Arguments

:: Socket

Socket to write to

-> Int

Status Code to send

-> [(ByteString, [ByteString])]

HTTP headers (Header,["value1", "value2"])

-> ByteString

Body

-> IO () 

Send a HTTP reply Sends a reply with the given parameters

statusMsg Source

Arguments

:: Int

Status code (ex. 404)

-> ByteString

Status message (ex. "404 Not Found")

Status Messages Returns status message from a given status id

subBS :: Int -> Int -> ByteString -> ByteString Source

Get a substring of a ByteString

trim :: ByteString -> ByteString Source

Trim whitespace from headers