This commit is contained in:
xing 2023-05-04 21:06:27 +08:00
parent f9b565294f
commit 2d2c6445e8
5 changed files with 13 additions and 7 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
wp-go.iml
config.yaml
err.log
plugins

View File

@ -77,6 +77,7 @@ func SetupRouter() *gin.Engine {
r.GET("/p/:id/feed", actions.PostFeed)
r.GET("/feed", actions.Feed)
r.GET("/comments/feed", actions.CommentsFeed)
//r.NoRoute(actions.ThemeHook(constraints.NoRoute))
commentMiddleWare, _ := middleware.FlowLimit(c.MaxRequestSleepNum, 5, c.CacheTime.SleepTime)
r.POST("/comment", commentMiddleWare, actions.PostComment)
if c.Pprof != "" {

View File

@ -9,6 +9,8 @@ const (
Author = "Author"
Detail = "Detail"
NoRoute = "NoRoute"
Ok = "Ok"
Error404 = "Error404"
ParamError = "ParamError"

View File

@ -45,22 +45,22 @@ func LoadPlugins() {
return
}
for _, entry := range glob {
f := filepath.Join(dirPath, entry)
p, err := plugin.Open(f)
p, err := plugin.Open(entry)
if err != nil {
logs.Error(err, "读取插件错误", f)
logs.Error(err, "读取插件错误", entry)
continue
}
name := filepath.Ext(entry)
name = str.FirstUpper(entry[0 : len(entry)-len(name)])
name = filepath.Base(entry[0 : len(entry)-len(name)])
name = str.FirstUpper(name)
pl, err := p.Lookup(name)
if err != nil {
logs.Error(err, "插件lookup错误", f)
logs.Error(err, "插件lookup错误", entry)
continue
}
plu, ok := pl.(func(*wp.Handle))
if !ok {
logs.Error(errors.New("switch func(*wp.Handle) fail"), "插件转换错误", f)
logs.Error(errors.New("switch func(*wp.Handle) fail"), "插件转换错误", entry)
continue
}
RegisterPlugin(name, plu)

View File

@ -92,7 +92,9 @@ postOrder: "desc"
uploadDir: ""
# pprof route path 为空表示不开启pprof,否则为pprof的路由
pprof: "/debug/pprof"
# 程序插件
# 要使用的程序插件
plugins: ["enlightjs"]
# 插件存放路径
pluginPath: "./plugins"
# 列表页面post使用的插件
listPagePlugins: ["passwordProject","digest","twentyseventeen_postThumbnail"]