-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Provides some basic WAI handlers and middleware. -- -- The goal here is to provide common features without many dependencies. @package wai-extra @version 1.2.0.4 module Network.Wai.Middleware.Vhost vhost :: [(Request -> Bool, Application)] -> Application -> Application redirectWWW :: Text -> Application -> Application module Network.Wai.Middleware.Rewrite -- | rewrite based on your own conversion rules rewrite :: ([Text] -> RequestHeaders -> IO [Text]) -> Middleware -- | rewrite based on your own conversion rules Example convert function: rewritePure :: ([Text] -> RequestHeaders -> [Text]) -> Middleware -- | Changes the request-method via first post-parameter _method. module Network.Wai.Middleware.MethodOverridePost -- | Allows overriding of the HTTP request method via the _method post -- string parameter. -- -- <ul> -- <li>Looks for the Content-Type requestHeader.</li> -- <li>If the header is set to application/x-www-form-urlencoded and the -- first POST parameter is _method then it changes the request-method to -- the value of that parameter.</li> -- <li>This middlware only applies when the initial request method is -- POST.</li> -- </ul> methodOverridePost :: Middleware module Network.Wai.Middleware.MethodOverride -- | Allows overriding of the HTTP request method via the _method query -- string parameter. -- -- This middlware only applies when the initial request method is POST. -- This allow submitting of normal HTML forms, without worries of -- semantics mismatches in the HTTP spec. methodOverride :: Middleware -- | Automatic wrapping of JSON responses to convert into JSONP. module Network.Wai.Middleware.Jsonp -- | Wrap json responses in a jsonp callback. -- -- Basically, if the user requested a "text/javascript" and supplied a -- "callback" GET parameter, ask the application for an -- "application/json" response, then convern that into a JSONP response, -- having a content type of "text/javascript" and calling the specified -- callback function. jsonp :: Middleware -- | Automatic gzip compression of responses. module Network.Wai.Middleware.Gzip -- | Use gzip to compress the body of the response. -- -- Analyzes the "Accept-Encoding" header from the client to determine if -- gzip is supported. -- -- Possible future enhancements: -- -- <ul> -- <li>Only compress if the response is above a certain size.</li> -- </ul> gzip :: GzipSettings -> Middleware data GzipSettings gzipFiles :: GzipSettings -> GzipFiles data GzipFiles GzipIgnore :: GzipFiles GzipCompress :: GzipFiles GzipCacheFolder :: FilePath -> GzipFiles -- | The default value for this type. def :: Default a => a defaultCheckMime :: ByteString -> Bool instance Show GzipFiles instance Eq GzipFiles instance Read GzipFiles instance Default GzipSettings -- | Some helpers for parsing data out of a raw WAI <a>Request</a>. module Network.Wai.Parse -- | Parse the HTTP accept string to determine supported content types. parseHttpAccept :: ByteString -> [ByteString] parseRequestBody :: BackEnd y -> Request -> ResourceT IO ([Param], [File y]) data RequestBodyType UrlEncoded :: RequestBodyType Multipart :: ByteString -> RequestBodyType getRequestBodyType :: Request -> Maybe RequestBodyType sinkRequestBody :: BackEnd y -> RequestBodyType -> Sink ByteString (ResourceT IO) ([Param], [File y]) conduitRequestBody :: BackEnd y -> RequestBodyType -> Conduit ByteString (ResourceT IO) (Either Param (File y)) -- | Store uploaded files in memory lbsBackEnd :: BackEnd ByteString -- | Save uploaded files on disk as temporary files tempFileBackEnd :: BackEnd FilePath -- | A destination for file data, with concrete implemtations provided by -- <a>lbsBackEnd</a> and <a>tempFileBackEnd</a> data BackEnd y BackEnd :: IO x -> (x -> ByteString -> IO x) -> (x -> IO y) -> (y -> IO ()) -> BackEnd y initialize :: BackEnd y -> IO x append :: BackEnd y -> x -> ByteString -> IO x close :: BackEnd y -> x -> IO y finalize :: BackEnd y -> y -> IO () type Param = (ByteString, ByteString) type File y = (ByteString, FileInfo y) -- | Information on an uploaded file. data FileInfo c FileInfo :: ByteString -> ByteString -> c -> FileInfo c fileName :: FileInfo c -> ByteString fileContentType :: FileInfo c -> ByteString fileContent :: FileInfo c -> c -- | This function has been renamed to <a>lbsBackEnd</a> lbsSink :: BackEnd ByteString -- | This function has been renamed to <a>tempFileBackEnd</a> tempFileSink :: BackEnd FilePath instance Eq c => Eq (FileInfo c) instance Show c => Show (FileInfo c) instance Eq Bound instance Show Bound module Network.Wai.Middleware.RequestLogger -- | Production request logger middleware. Implemented on top of -- <a>logCallback</a>, but prints to <a>stdout</a> logStdout :: Middleware -- | Prints a message using the given callback function for each request. -- Designed for fast production use at the expense of convenience. In -- particular, no POST parameter information is currently given -- -- This is lower-level - use <a>logStdout</a> unless you need this -- greater control logCallback :: (ByteString -> IO ()) -> Middleware -- | Development request logger middleware. Implemented on top of -- <a>logCallbackDev</a>, but prints to <a>stdout</a> -- -- Flushes <a>stdout</a> on each request, which would be inefficient in -- production use. Use <a>logStdout</a> in production. logStdoutDev :: Middleware -- | Prints a message using the given callback function for each request. -- This is not for serious production use- it is inefficient. It -- immediately consumes a POST body and fills it back in and is otherwise -- inefficient -- -- Note that it logs the request immediately when it is received. This -- meanst that you can accurately see the interleaving of requests. And -- if the app crashes you have still logged the request. However, if you -- are simulating 10 simultaneous users you may find this confusing. The -- request and response are connected by color on Unix and also by the -- request path. -- -- This is lower-level - use <a>logStdoutDev</a> unless you need greater -- control. -- -- Example ouput: -- -- <pre> -- GET search -- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 -- -- Status: 200 OK. search -- -- GET static/css/normalize.css -- Accept: text/css,*/*;q=0.1 -- GET [("LXwioiBG","")] -- -- Status: 304 Not Modified. static/css/normalize.css -- </pre> logCallbackDev :: (ByteString -> IO ()) -> Middleware logHandle :: (ByteString -> IO ()) -> Middleware logHandleDev :: (ByteString -> IO ()) -> Middleware module Network.Wai.Middleware.CleanPath cleanPath :: ([Text] -> Either ByteString [Text]) -> ByteString -> ([Text] -> Application) -> Application -- | Automatically produce responses to HEAD requests based on the -- underlying applications GET response. module Network.Wai.Middleware.Autohead autohead :: Middleware module Network.Wai.Middleware.AcceptOverride acceptOverride :: Middleware -- | Backend for Common Gateway Interface. Almost all users should use the -- <a>run</a> function. module Network.Wai.Handler.CGI -- | Run an application using CGI. run :: Application -> IO () -- | Some web servers provide an optimization for sending files via a -- sendfile system call via a special header. To use this feature, -- provide that header name here. runSendfile :: ByteString -> Application -> IO () -- | A generic CGI helper, which allows other backends (FastCGI and SCGI) -- to use the same code as CGI. Most users will not need this function, -- and can stick with <a>run</a> or <a>runSendfile</a>. runGeneric :: [(String, String)] -> (Int -> Source (ResourceT IO) ByteString) -> (ByteString -> IO ()) -> Maybe ByteString -> Application -> IO () requestBodyFunc :: (Int -> IO (Maybe ByteString)) -> Int -> Source (ResourceT IO) ByteString