ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 一、main.go中的main中添加 ~~~ beego.InsertFilter("/mains/*", beego.BeforeRouter, utils.CmsLoginFilter) ~~~ 实例: ~~~ func main() { beego.InsertFilter("/mains/*", beego.BeforeRouter, utils.CmsLoginFilter) beego.Run() } ~~~ 过滤器代码: ~~~ package utils import ( "github.com/astaxie/beego" "github.com/astaxie/beego/context" ) func CmsLoginFilter(ctx *context.Context) { cms_user_name := ctx.Input.Session("user_name") if cms_user_name == nil { ctx.Redirect(302, beego.URLFor("LoginController.Get")) } } ~~~