From 95bca77f379d3fe10d7ba1d49c90c09936cb1ff4 Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Wed, 17 Nov 2021 16:05:20 +0800 Subject: [PATCH] fix: query param cause 404 notfound --- cmd/gterm/main.go | 5 ++++- gterm.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/gterm/main.go b/cmd/gterm/main.go index 6b540f9..d388599 100644 --- a/cmd/gterm/main.go +++ b/cmd/gterm/main.go @@ -57,6 +57,7 @@ func main() { Addr: flagAddr, Handler: Middleware(g), } + klog.Info("gterm starting at ", flagAddr) err := server.ListenAndServe() if err != nil { panic(err) @@ -71,12 +72,14 @@ func Middleware(next http.Handler) http.Handler { log.Error(err) } }() + ip := ksrv.GetIP(r) if flagAllowIP != "" { - if !ksrv.MatchIPGlob(ksrv.GetIP(r), flagAllowIP) { + if !ksrv.MatchIPGlob(ip, flagAllowIP) { w.WriteHeader(http.StatusForbidden) w.Write([]byte("permission denied")) } } next.ServeHTTP(w, r) + log.Debug(ip, " ", r.URL.String()) }) } diff --git a/gterm.go b/gterm.go index e291a26..11b714d 100644 --- a/gterm.go +++ b/gterm.go @@ -101,7 +101,7 @@ type App struct { } func (g *GTerm) App(w http.ResponseWriter, r *http.Request) { - if r.URL.String() == "/" { + if r.URL.Path == "/" { tmpl.Execute(w, App{g.AppName}) return }