func canSkipSessionMiddleware(req *wcg.Request) bool { return req.Header(request.APITokenHeader) != "" || request.IsStatic(req) || request.IsHook(req) || request.IsCron(req) || request.IsTask(req) }
func byHeader(router *wcg.Router, configure func()) { router.Before(wcg.NewNamedHandler("HeaderAuth", func(res *wcg.Response, req *wcg.Request) { if !request.ByGuest(req) { // already authenticated req.Logger.Warnf("request.Authorize is called more than once.") return } // req.Logger.Infof("Token Authorization: %s", tokenString) if request.IsTask(req) { req.User = request.NewTaskUser(req) } else if request.IsCron(req) { req.User = request.CronUser } else { authorizeByAPIToken(req) } })) configure() }