airship-0.4.2.0: A Webmachine-inspired HTTP library

Safe HaskellNone
LanguageHaskell2010

Airship.Helpers

Synopsis

Documentation

parseFormData :: Request -> IO ([Param], [File ByteString]) Source

Parse form data uploaded with a Content-Type of either www-form-urlencoded or multipart/form-data to return a list of parameter names and values and a list of uploaded files and their information.

contentTypeMatches :: Monad m => [MediaType] -> Webmachine m Bool Source

Returns True if the request's Content-Type header is one of the provided media types. If the Content-Type header is not present, this function will return True.

redirectTemporarily :: Monad m => ByteString -> Webmachine m a Source

Issue an HTTP 302 (Found) response, with location as the destination.

redirectPermanently :: Monad m => ByteString -> Webmachine m a Source

Issue an HTTP 301 (Moved Permantently) response, with location as the destination.

resourceToWai :: AirshipConfig -> RoutingSpec IO () -> Resource IO -> Application Source

Given a RoutingSpec, a 404 resource, and a user state s, construct a WAI Application.

resourceToWaiT :: Monad m => AirshipConfig -> (Request -> m Response -> IO Response) -> RoutingSpec m () -> Resource m -> Application Source

Given a RoutingSpec, a 404 resource, and a user state s, construct a WAI Application.

lookupParam :: Monad m => Text -> Webmachine m Text Source

Lookup routing parameter and return 500 Internal Server Error if not found. Not finding the paramter usually means the route doesn't match what the resource is expecting.

lookupParam' :: Monad m => Text -> Webmachine m (Maybe Text) Source

Lookup routing parameter.