fix: query param cause 404 notfound
parent
96209b847a
commit
95bca77f37
|
@ -57,6 +57,7 @@ func main() {
|
||||||
Addr: flagAddr,
|
Addr: flagAddr,
|
||||||
Handler: Middleware(g),
|
Handler: Middleware(g),
|
||||||
}
|
}
|
||||||
|
klog.Info("gterm starting at ", flagAddr)
|
||||||
err := server.ListenAndServe()
|
err := server.ListenAndServe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -71,12 +72,14 @@ func Middleware(next http.Handler) http.Handler {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
ip := ksrv.GetIP(r)
|
||||||
if flagAllowIP != "" {
|
if flagAllowIP != "" {
|
||||||
if !ksrv.MatchIPGlob(ksrv.GetIP(r), flagAllowIP) {
|
if !ksrv.MatchIPGlob(ip, flagAllowIP) {
|
||||||
w.WriteHeader(http.StatusForbidden)
|
w.WriteHeader(http.StatusForbidden)
|
||||||
w.Write([]byte("permission denied"))
|
w.Write([]byte("permission denied"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
next.ServeHTTP(w, r)
|
next.ServeHTTP(w, r)
|
||||||
|
log.Debug(ip, " ", r.URL.String())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
2
gterm.go
2
gterm.go
|
@ -101,7 +101,7 @@ type App struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GTerm) App(w http.ResponseWriter, r *http.Request) {
|
func (g *GTerm) App(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.String() == "/" {
|
if r.URL.Path == "/" {
|
||||||
tmpl.Execute(w, App{g.AppName})
|
tmpl.Execute(w, App{g.AppName})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue