完善
This commit is contained in:
parent
f9b565294f
commit
2d2c6445e8
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@
|
||||||
wp-go.iml
|
wp-go.iml
|
||||||
config.yaml
|
config.yaml
|
||||||
err.log
|
err.log
|
||||||
|
plugins
|
|
@ -77,6 +77,7 @@ func SetupRouter() *gin.Engine {
|
||||||
r.GET("/p/:id/feed", actions.PostFeed)
|
r.GET("/p/:id/feed", actions.PostFeed)
|
||||||
r.GET("/feed", actions.Feed)
|
r.GET("/feed", actions.Feed)
|
||||||
r.GET("/comments/feed", actions.CommentsFeed)
|
r.GET("/comments/feed", actions.CommentsFeed)
|
||||||
|
//r.NoRoute(actions.ThemeHook(constraints.NoRoute))
|
||||||
commentMiddleWare, _ := middleware.FlowLimit(c.MaxRequestSleepNum, 5, c.CacheTime.SleepTime)
|
commentMiddleWare, _ := middleware.FlowLimit(c.MaxRequestSleepNum, 5, c.CacheTime.SleepTime)
|
||||||
r.POST("/comment", commentMiddleWare, actions.PostComment)
|
r.POST("/comment", commentMiddleWare, actions.PostComment)
|
||||||
if c.Pprof != "" {
|
if c.Pprof != "" {
|
||||||
|
|
|
@ -9,6 +9,8 @@ const (
|
||||||
Author = "Author"
|
Author = "Author"
|
||||||
Detail = "Detail"
|
Detail = "Detail"
|
||||||
|
|
||||||
|
NoRoute = "NoRoute"
|
||||||
|
|
||||||
Ok = "Ok"
|
Ok = "Ok"
|
||||||
Error404 = "Error404"
|
Error404 = "Error404"
|
||||||
ParamError = "ParamError"
|
ParamError = "ParamError"
|
||||||
|
|
|
@ -45,22 +45,22 @@ func LoadPlugins() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, entry := range glob {
|
for _, entry := range glob {
|
||||||
f := filepath.Join(dirPath, entry)
|
p, err := plugin.Open(entry)
|
||||||
p, err := plugin.Open(f)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Error(err, "读取插件错误", f)
|
logs.Error(err, "读取插件错误", entry)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
name := filepath.Ext(entry)
|
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)
|
pl, err := p.Lookup(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Error(err, "插件lookup错误", f)
|
logs.Error(err, "插件lookup错误", entry)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
plu, ok := pl.(func(*wp.Handle))
|
plu, ok := pl.(func(*wp.Handle))
|
||||||
if !ok {
|
if !ok {
|
||||||
logs.Error(errors.New("switch func(*wp.Handle) fail"), "插件转换错误", f)
|
logs.Error(errors.New("switch func(*wp.Handle) fail"), "插件转换错误", entry)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
RegisterPlugin(name, plu)
|
RegisterPlugin(name, plu)
|
||||||
|
|
|
@ -92,7 +92,9 @@ postOrder: "desc"
|
||||||
uploadDir: ""
|
uploadDir: ""
|
||||||
# pprof route path 为空表示不开启pprof,否则为pprof的路由
|
# pprof route path 为空表示不开启pprof,否则为pprof的路由
|
||||||
pprof: "/debug/pprof"
|
pprof: "/debug/pprof"
|
||||||
# 程序插件
|
# 要使用的程序插件名
|
||||||
plugins: ["enlightjs"]
|
plugins: ["enlightjs"]
|
||||||
|
# 插件存放路径
|
||||||
|
pluginPath: "./plugins"
|
||||||
# 列表页面post使用的插件
|
# 列表页面post使用的插件
|
||||||
listPagePlugins: ["passwordProject","digest","twentyseventeen_postThumbnail"]
|
listPagePlugins: ["passwordProject","digest","twentyseventeen_postThumbnail"]
|
Loading…
Reference in New Issue
Block a user