2017-04-30 22:13:12 +08:00
|
|
|
package routers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/astaxie/beego"
|
|
|
|
"github.com/astaxie/beego/context"
|
2017-06-14 09:23:29 +08:00
|
|
|
"github.com/lifei6671/mindoc/conf"
|
|
|
|
"github.com/lifei6671/mindoc/models"
|
2017-04-30 22:13:12 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
var FilterUser = func(ctx *context.Context) {
|
|
|
|
_, ok := ctx.Input.Session(conf.LoginSessionName).(models.Member)
|
|
|
|
|
|
|
|
if !ok {
|
|
|
|
ctx.Redirect(302, beego.URLFor("AccountController.Login"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
beego.InsertFilter("/manager",beego.BeforeRouter,FilterUser)
|
|
|
|
beego.InsertFilter("/manager/*",beego.BeforeRouter,FilterUser)
|
|
|
|
beego.InsertFilter("/setting",beego.BeforeRouter,FilterUser)
|
|
|
|
beego.InsertFilter("/setting/*",beego.BeforeRouter,FilterUser)
|
|
|
|
beego.InsertFilter("/book",beego.BeforeRouter,FilterUser)
|
|
|
|
beego.InsertFilter("/book/*",beego.BeforeRouter,FilterUser)
|
|
|
|
beego.InsertFilter("/api/*",beego.BeforeRouter,FilterUser)
|
2017-05-03 14:22:05 +08:00
|
|
|
|
|
|
|
var FinishRouter = func(ctx *context.Context) {
|
2017-05-11 13:39:34 +08:00
|
|
|
ctx.ResponseWriter.Header().Add("MinDoc-Version",conf.VERSION)
|
2017-05-03 14:22:05 +08:00
|
|
|
ctx.ResponseWriter.Header().Add("MinDoc-Site","http://www.iminho.me")
|
|
|
|
}
|
|
|
|
|
|
|
|
beego.InsertFilter("/*",beego.BeforeRouter ,FinishRouter, false)
|
2017-04-30 22:13:12 +08:00
|
|
|
}
|