mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 09:00:04 +08:00
插件增加静态文件目录自动映射,优化插件模板引擎与主模块的耦合关系
This commit is contained in:
@@ -11,16 +11,26 @@ import (
|
||||
"hotgo/internal/consts"
|
||||
)
|
||||
|
||||
func GetTag(name string) string {
|
||||
return consts.AddonsTag + name
|
||||
// GetModulePath 获取指定模块相对路径
|
||||
func GetModulePath(name string) string {
|
||||
return "./" + consts.AddonsDir + "/" + name
|
||||
}
|
||||
|
||||
func Tpl(name, tpl string) string {
|
||||
return consts.AddonsDir + "/" + name + "/" + tpl
|
||||
// ViewPath 默认的插件模板路径
|
||||
func ViewPath(name string) string {
|
||||
return consts.AddonsDir + "/" + name + "/" + "resource/template"
|
||||
}
|
||||
|
||||
// StaticPath 默认的插件静态路映射关系
|
||||
// 最终效果:对外访问地址:/addons/插件模块名称;静态资源路径:/addons/插件模块名称/设置的子路径。
|
||||
// 如果你不喜欢现在的路由风格,可以自行调整
|
||||
func StaticPath(name, path string) (string, string) {
|
||||
return "/" + consts.AddonsDir + "/" + name, consts.AddonsDir + "/" + name + "/" + path
|
||||
}
|
||||
|
||||
// RouterPrefix 路由前缀
|
||||
// 最终效果:/应用名称/插件模块名称/xxx/xxx。如果你不喜欢现在的路由风格,可以自行调整
|
||||
// 最终效果:/应用名称/插件模块名称/xxx/xxx。
|
||||
// 如果你不喜欢现在的路由风格,可以自行调整
|
||||
func RouterPrefix(ctx context.Context, app, name string) string {
|
||||
var prefix = "/"
|
||||
if app != "" {
|
||||
|
Reference in New Issue
Block a user