fix: query param cause 404 notfound

master
Evan Chen 2021-11-17 16:05:20 +08:00
parent 96209b847a
commit 95bca77f37
2 changed files with 5 additions and 2 deletions

View File

@ -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())
})
}

View File

@ -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
}