|
|
@ -5,6 +5,7 @@ import (
|
|
|
|
"github.com/veypi/OneAuth/libs/fs"
|
|
|
|
"github.com/veypi/OneAuth/libs/fs"
|
|
|
|
"github.com/veypi/OneBD"
|
|
|
|
"github.com/veypi/OneBD"
|
|
|
|
"github.com/veypi/OneBD/rfc"
|
|
|
|
"github.com/veypi/OneBD/rfc"
|
|
|
|
|
|
|
|
"github.com/veypi/utils"
|
|
|
|
"github.com/veypi/utils/log"
|
|
|
|
"github.com/veypi/utils/log"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -16,19 +17,32 @@ import (
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
|
|
func Router(r OneBD.Router) {
|
|
|
|
func Router(r OneBD.Router) {
|
|
|
|
|
|
|
|
// 用户私有文件
|
|
|
|
usrF := fs.FS{
|
|
|
|
usrF := fs.FS{
|
|
|
|
RootDir: cfg.CFG.FireDir + "/usr/",
|
|
|
|
RootDir: utils.PathJoin(cfg.CFG.FireDir, "usr"),
|
|
|
|
|
|
|
|
UrlRoot: utils.PathJoin(cfg.CFG.FileUrlPrefix, "usr"),
|
|
|
|
MountFunc: userFileChecker,
|
|
|
|
MountFunc: userFileChecker,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.Info().Msgf("start file server on %s", cfg.CFG.Host)
|
|
|
|
log.Info().Msgf("start file server on %s", cfg.CFG.Host)
|
|
|
|
r.Set("/usr/", usrF.ServeHTTP, rfc.MethodAll)
|
|
|
|
r.Set("/usr/", usrF.ServeHTTP, rfc.MethodAll)
|
|
|
|
r.Set("/usr/*", usrF.ServeHTTP, rfc.MethodAll)
|
|
|
|
r.Set("/usr/*", usrF.ServeHTTP, rfc.MethodAll)
|
|
|
|
|
|
|
|
// 应用存储文件
|
|
|
|
appF := fs.FS{
|
|
|
|
appF := fs.FS{
|
|
|
|
RootDir: cfg.CFG.FireDir + "/app/",
|
|
|
|
RootDir: utils.PathJoin(cfg.CFG.FireDir, "app"),
|
|
|
|
|
|
|
|
UrlRoot: utils.PathJoin(cfg.CFG.FileUrlPrefix, "app"),
|
|
|
|
MountFunc: appFileChecker,
|
|
|
|
MountFunc: appFileChecker,
|
|
|
|
DisabledAlert: true,
|
|
|
|
DisabledAlert: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
r.Set("/app/:uuid/", appF.ServeHTTP, rfc.MethodAll)
|
|
|
|
r.Set("/app/:uuid/", appF.ServeHTTP, rfc.MethodAll)
|
|
|
|
r.Set("/app/:uuid/*preifx", appF.ServeHTTP, rfc.MethodAll)
|
|
|
|
r.Set("/app/:uuid/*prefix", appF.ServeHTTP, rfc.MethodAll)
|
|
|
|
r.Set("/ursapp/:id/:uuid/*prefix", nil)
|
|
|
|
r.Set("/ursapp/:id/:uuid/*prefix", nil)
|
|
|
|
|
|
|
|
// 公共文件 读取无需权限
|
|
|
|
|
|
|
|
pubF := fs.FS{
|
|
|
|
|
|
|
|
RootDir: utils.PathJoin(cfg.CFG.FireDir, "public"),
|
|
|
|
|
|
|
|
UrlRoot: utils.PathJoin(cfg.CFG.FileUrlPrefix, "public"),
|
|
|
|
|
|
|
|
MountFunc: pubFileChecker,
|
|
|
|
|
|
|
|
DisabledAlert: true,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
r.Set("/public/app/:uuid/*prefix", pubF.ServeHTTP, rfc.MethodAll)
|
|
|
|
|
|
|
|
r.Set("/public/*prefix", pubF.ServeHTTP, rfc.MethodAll)
|
|
|
|
}
|
|
|
|
}
|
|
|
|