Skip to content

Commit edbc5c8

Browse files
authored
Use Request.URL.RequestURI() for fcgi (#14312) (#14314)
1 parent 954aeef commit edbc5c8

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

custom/conf/app.example.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ MACARON = file
867867
ROUTER_LOG_LEVEL = Info
868868
ROUTER = console
869869
ENABLE_ACCESS_LOG = false
870-
ACCESS_LOG_TEMPLATE = {{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"
870+
ACCESS_LOG_TEMPLATE = {{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"
871871
ACCESS = file
872872
; Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace"
873873
LEVEL = Info

routers/routes/chi.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ func LoggerHandler(level log.Level) func(next http.Handler) http.Handler {
8686
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
8787
start := time.Now()
8888

89-
_ = log.GetLogger("router").Log(0, level, "Started %s %s for %s", log.ColoredMethod(req.Method), req.RequestURI, req.RemoteAddr)
89+
_ = log.GetLogger("router").Log(0, level, "Started %s %s for %s", log.ColoredMethod(req.Method), req.URL.RequestURI(), req.RemoteAddr)
9090

9191
next.ServeHTTP(w, req)
9292

9393
ww := middleware.NewWrapResponseWriter(w, req.ProtoMajor)
9494

9595
status := ww.Status()
96-
_ = log.GetLogger("router").Log(0, level, "Completed %s %s %v %s in %v", log.ColoredMethod(req.Method), req.RequestURI, log.ColoredStatus(status), log.ColoredStatus(status, http.StatusText(status)), log.ColoredTime(time.Since(start)))
96+
_ = log.GetLogger("router").Log(0, level, "Completed %s %s %v %s in %v", log.ColoredMethod(req.Method), req.URL.RequestURI(), log.ColoredStatus(status), log.ColoredStatus(status, http.StatusText(status)), log.ColoredTime(time.Since(start)))
9797
})
9898
}
9999
}
@@ -107,12 +107,12 @@ func storageHandler(storageSetting setting.Storage, prefix string, objStore stor
107107
return
108108
}
109109

110-
if !strings.HasPrefix(req.RequestURI, "/"+prefix) {
110+
if !strings.HasPrefix(req.URL.RequestURI(), "/"+prefix) {
111111
next.ServeHTTP(w, req)
112112
return
113113
}
114114

115-
rPath := strings.TrimPrefix(req.RequestURI, "/"+prefix)
115+
rPath := strings.TrimPrefix(req.URL.RequestURI(), "/"+prefix)
116116
u, err := objStore.URL(rPath, path.Base(rPath))
117117
if err != nil {
118118
if os.IsNotExist(err) || errors.Is(err, os.ErrNotExist) {
@@ -139,12 +139,12 @@ func storageHandler(storageSetting setting.Storage, prefix string, objStore stor
139139
return
140140
}
141141

142-
if !strings.HasPrefix(req.RequestURI, "/"+prefix) {
142+
if !strings.HasPrefix(req.URL.RequestURI(), "/"+prefix) {
143143
next.ServeHTTP(w, req)
144144
return
145145
}
146146

147-
rPath := strings.TrimPrefix(req.RequestURI, "/"+prefix)
147+
rPath := strings.TrimPrefix(req.URL.RequestURI(), "/"+prefix)
148148
rPath = strings.TrimPrefix(rPath, "/")
149149

150150
fi, err := objStore.Stat(rPath)

0 commit comments

Comments
 (0)