1234567891011121314151617181920212223242526272829303132 |
- package main
- import (
- "net/http"
- "strings"
- )
- func AuthFsHandler(handler http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-
- if strings.HasPrefix(r.URL.Path, "/script/") || strings.HasPrefix(r.URL.Path, "/img/public/") || r.URL.Path == "/login.html" || r.URL.Path == "/favicon.png" {
- handler.ServeHTTP(w, r)
- return
- }
-
- if !authAgent.CheckAuth(r) {
- http.Redirect(w, r, "/login.html", http.StatusTemporaryRedirect)
- return
- }
-
- handler.ServeHTTP(w, r)
- })
- }
|