module Network.MoHWS.Module where
import qualified Network.MoHWS.HTTP.Response as Response
import qualified Network.MoHWS.Server.Request as ServerRequest
import Control.Monad.Trans.Maybe (MaybeT, )
import Control.Monad (mzero, )
import Network.Socket (HostName, )
data T body = Cons
{
isServerHost :: HostName -> Bool,
translatePath :: String -> String -> MaybeT IO FilePath,
tweakRequest :: ServerRequest.T body -> IO (ServerRequest.T body),
handleRequest :: ServerRequest.T body -> MaybeT IO (Response.T body)
}
empty :: T body
empty =
Cons {
isServerHost = \_ -> False,
translatePath = \_ _ -> mzero,
tweakRequest = \r -> return r,
handleRequest = \_ -> mzero
}
tweakFilename ::
(server -> FilePath -> IO FilePath) ->
server -> ServerRequest.T body -> IO (ServerRequest.T body)
tweakFilename f conf req =
do filename <- f conf (ServerRequest.serverFilename req)
return $ req { ServerRequest.serverFilename = filename }