module Network.Wai.Application.Classic.FileInfo where
import Network.Wai
import Network.Wai.Application.Classic.Path
import Network.Wai.Application.Classic.Types
pathinfoToFilePath :: Request -> FileRoute -> Path
pathinfoToFilePath :: Request -> FileRoute -> Path
pathinfoToFilePath Request
req FileRoute
filei = Path
path'
where
path :: Path
path = Request -> Path
rawPathInfo Request
req
src :: Path
src = FileRoute -> Path
fileSrc FileRoute
filei
dst :: Path
dst = FileRoute -> Path
fileDst FileRoute
filei
path' :: Path
path' = Path
dst Path -> Path -> Path
</> (Path
path Path -> Path -> Path
<\> Path
src)
addIndex :: FileAppSpec -> Path -> Path
addIndex :: FileAppSpec -> Path -> Path
addIndex FileAppSpec
spec Path
path
| Path -> Bool
hasTrailingPathSeparator Path
path = Path
path Path -> Path -> Path
</> FileAppSpec -> Path
indexFile FileAppSpec
spec
| Bool
otherwise = Path
path
redirectPath :: FileAppSpec -> Path -> Maybe Path
redirectPath :: FileAppSpec -> Path -> Maybe Path
redirectPath FileAppSpec
spec Path
path
| Path -> Bool
hasTrailingPathSeparator Path
path = Maybe Path
forall a. Maybe a
Nothing
| Bool
otherwise = Path -> Maybe Path
forall a. a -> Maybe a
Just (Path
path Path -> Path -> Path
</> FileAppSpec -> Path
indexFile FileAppSpec
spec)