package filter import ( "app.yhyue.com/moapp/jybase/go-xweb/xweb" "net/http" ) //登录限制 type sessionfilter struct { App *xweb.App } //继承过滤器方法 func (l *sessionfilter) Do(w http.ResponseWriter, req *http.Request) bool { session := l.App.SessionManager.Session(req, w) if session.Get("userId") == nil { w.Write([]byte("{\"error\":\"需要登录!\"}")) return false } return true }