Add querylog
This commit is contained in:
parent
9a612a6281
commit
42ddb1b77d
4
main.go
4
main.go
|
@ -29,6 +29,8 @@ func init() {
|
|||
func main() {
|
||||
r := mux.NewRouter()
|
||||
r.Use(BasicAuth)
|
||||
r.Use(QueryLog)
|
||||
|
||||
r.PathPrefix("/").Handler(http.StripPrefix("/", enhancedfileserver.FileServer(http.Dir("./"))))
|
||||
|
||||
a := fmt.Sprintf("%s:%d", c.Listen, c.Port)
|
||||
|
@ -41,7 +43,7 @@ func BasicAuth(next http.Handler) http.Handler {
|
|||
if c.Username != "" && c.Password != "" {
|
||||
user, pass, ok := r.BasicAuth()
|
||||
if !ok || user != c.Username || pass != c.Password {
|
||||
w.Header().Set("WWW-Authenticate", `Basic realm="mydomain"`)
|
||||
w.Header().Set("WWW-Authenticate", `Basic realm="mydomains"`)
|
||||
|
||||
http.Error(w, "Unauthorized", http.StatusUnauthorized)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue