完善
This commit is contained in:
parent
f9b565294f
commit
2d2c6445e8
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@
|
|||
wp-go.iml
|
||||
config.yaml
|
||||
err.log
|
||||
plugins
|
|
@ -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 != "" {
|
||||
|
|
|
@ -9,6 +9,8 @@ const (
|
|||
Author = "Author"
|
||||
Detail = "Detail"
|
||||
|
||||
NoRoute = "NoRoute"
|
||||
|
||||
Ok = "Ok"
|
||||
Error404 = "Error404"
|
||||
ParamError = "ParamError"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"]
|
Loading…
Reference in New Issue
Block a user