15 Star 246 Fork 42

杰克/elk-blog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
controller.go 897 Bytes
一键复制 编辑 原始数据 按行查看 历史
package admin
import (
"gitee.com/jikey/elk-blog/setting"
"github.com/gin-gonic/gin"
"reflect"
"strings"
)
type ControllerInterface interface {
beforeAction(c *gin.Context) error
afterAction(c *gin.Context) error
}
type Controller struct {
actionName string
viewDir string // view 默认文件夹(相对路径)
this ControllerInterface // 实例
}
var Site = setting.Config.Site
func (ctrl *Controller) Init(this ControllerInterface) error {
ctrl.this = this
className := reflect.TypeOf(ctrl.this).String()
className = className[strings.LastIndex(className, ".")+1:]
ctrl.actionName = strings.TrimRight(className, "Controller")
return nil
}
/*
*
action调用前回调
*/
func (ctrl *Controller) beforeAction(c *gin.Context) error {
return nil
}
/*
*
action调用后回调
*/
func (ctrl *Controller) afterAction(c *gin.Context) error {
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/jikey/elk-blog.git
git@gitee.com:jikey/elk-blog.git
jikey
elk-blog
elk-blog
d402f94cccdf

搜索帮助