internal/log: Implement logging of HOST when using subrequest auth (#1027)
* internal/log: Implement logging of HOST when using subrequest auth The host header wouldn't be set on subrequest auth, so we need to look for X-Forwarded-Host header when logging requests. * chore: add changelog entry --------- Signed-off-by: Xe Iaso <xe.iaso@techaro.lol> Co-authored-by: Xe Iaso <xe.iaso@techaro.lol>
This commit is contained in:
parent
99bd06b8c3
commit
01f55cf552
3 changed files with 44 additions and 2 deletions
|
|
@ -27,8 +27,13 @@ func InitSlog(level string) {
|
|||
}
|
||||
|
||||
func GetRequestLogger(base *slog.Logger, r *http.Request) *slog.Logger {
|
||||
host := r.Host
|
||||
if host == "" {
|
||||
host = r.Header.Get("X-Forwarded-Host")
|
||||
}
|
||||
|
||||
return base.With(
|
||||
"host", r.Host,
|
||||
"host", host,
|
||||
"method", r.Method,
|
||||
"path", r.URL.Path,
|
||||
"user_agent", r.UserAgent(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue