func()

in auth.go [113:127]


func (s *Server) requireAuth(next http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		if s.isLoggedIn(r) {
			next.ServeHTTP(w, r)
			return
		}

		if s.config.RedirectToLogin {
			http.Redirect(w, r, s.buildLoginURL(r), http.StatusFound)
			return
		}

		http.Error(w, "401 Unauthorized", http.StatusUnauthorized)
	})
}