1234567891011121314151617181920212223242526 |
- package filter
- import (
- "net/http"
- "strings"
- "app.yhyue.com/moapp/jybase/go-xweb/xweb"
- )
- // 登录限制
- 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 req.RequestURI == "/jyActivity/getConfig/info" || strings.Contains(req.RequestURI, "/sse/") {
- return true
- }
- if session.Get("userId") == nil {
- w.Write([]byte(`{"error_code":-1,"error_msg":"需要登录!"}`))
- return false
- }
- return true
- }
|