{- |
Copyright: 2002, Simon Marlow.
Copyright: 2006, Bjorn Bringert.
Copyright: 2009, Henning Thielemann.
Show @index.html@ or another configured file
whenever the URI path is a directory.
However, this module gets only active
if the directory path is terminated with a slash.
Without a slash the relative paths will not be processed correct by the web clients
(they will consider relative paths as relative to the superdirectory).
See also "Network.MoHWS.Part.AddSlash".
-}moduleNetwork.MoHWS.Part.Index(Configuration,desc,)whereimportqualifiedNetwork.MoHWS.ModuleasModuleimportqualifiedNetwork.MoHWS.Module.DescriptionasModuleDescimportqualifiedNetwork.MoHWS.Server.RequestasServerRequestimportqualifiedNetwork.MoHWS.Server.ContextasServerContextimportNetwork.MoHWS.Logger.Error(debug,)importqualifiedNetwork.MoHWS.ConfigurationasConfigimportqualifiedNetwork.MoHWS.Configuration.AccessorasConfigAimportqualifiedNetwork.MoHWS.Configuration.ParserasConfigParserimportqualifiedData.Accessor.BasicasAccessorimportData.Accessor.Basic((.>))importNetwork.MoHWS.Utility(statFile,hasTrailingSlash,)importData.Maybe(fromMaybe,)importControl.Monad.Trans.Maybe(MaybeT,runMaybeT,)importControl.Monad.Trans.Class(lift,)importControl.Monad(guard,)importqualifiedSystem.FilePathasFilePathimportSystem.Posix(isDirectory,)desc::ModuleDesc.TbodyConfigurationdesc=ModuleDesc.empty{ModuleDesc.name="index",ModuleDesc.load=return.funs,ModuleDesc.configParser=parser,ModuleDesc.setDefltConfig=constdefltConfig}dataConfiguration=Configuration{index_::String}defltConfig::ConfigurationdefltConfig=Configuration{index_="index.html"}index::Accessor.TConfigurationStringindex=Accessor.fromSetGet(\xc->c{index_=x})index_parser::ConfigParser.TstConfigurationparser=ConfigParser.field"directoryindex"p_indexp_index::ConfigParser.TstConfigurationp_index=ConfigParser.set(ConfigA.extension.>index)$ConfigParser.stringLiteralfuns::ServerContext.TConfiguration->Module.Tbodyfunsst=Module.empty{Module.tweakRequest=tweakRequestst}tweakRequest::ServerContext.TConfiguration->ServerRequest.Tbody->IO(ServerRequest.Tbody)tweakRequest=Module.tweakFilenamefixPathfixPath::ServerContext.TConfiguration->FilePath->IOFilePathfixPathstfilename=letconf=ServerContext.configstinfmap(fromMaybefilename)$runMaybeT$doguard(hasTrailingSlashfilename)stat<-statFilefilenameguard(isDirectorystat)letindexFilename=FilePath.combinefilename$index_$Config.extensionconflift$debugst$"indexFilename = "++showindexFilename_<-statFileindexFilename-- check whether file existsreturnindexFilename