packages feed

wai-extra 0.2.1 → 0.2.2

raw patch · 2 files changed

+19/−6 lines, 2 files

Files

Network/Wai/Middleware/CleanPath.hs view
@@ -1,15 +1,23 @@ {-# LANGUAGE OverloadedStrings #-}-module Network.Wai.Middleware.CleanPath (cleanPath, cleanPathRel, splitPath) where+module Network.Wai.Middleware.CleanPath+    ( cleanPath+    , cleanPathRel+    , cleanPathFunc+    , splitPath+    ) where  import Network.Wai import qualified Data.ByteString.Char8 as B import qualified Data.ByteString.Lazy as L import Network.URI (unEscapeString) --- | Performs redirects as per 'splitPath'.-cleanPathRel :: B.ByteString -> ([String] -> Request -> IO Response) -> Request -> IO Response-cleanPathRel prefix app env =-    case splitPath $ pathInfo env of+cleanPathFunc :: (B.ByteString -> Either B.ByteString [String])+              -> B.ByteString+              -> ([String] -> Request -> IO Response)+              -> Request+              -> IO Response+cleanPathFunc splitter prefix app env =+    case splitter $ pathInfo env of         Right pieces -> app pieces env         Left p -> return                 . Response status301@@ -22,6 +30,11 @@                 Nothing -> B.empty                 Just ('?', _) -> queryString env                 _ -> B.cons '?' $ queryString env++-- | Performs redirects as per 'splitPath'.+cleanPathRel :: B.ByteString -> ([String] -> Request -> IO Response)+             -> Request -> IO Response+cleanPathRel = cleanPathFunc splitPath  cleanPath :: ([String] -> Request -> IO Response) -> Request -> IO Response cleanPath = cleanPathRel B.empty
wai-extra.cabal view
@@ -1,5 +1,5 @@ Name:                wai-extra-Version:             0.2.1+Version:             0.2.2 Synopsis:            Provides some basic WAI handlers and middleware. Description:         The goal here is to provide common features without many dependencies. License:             BSD3