diff options
| author | mo khan <mo@mokhan.ca> | 2025-05-24 01:32:31 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-05-24 01:32:31 -0600 |
| commit | 3044fd1170a003380a558918605d32491f9b45a5 (patch) | |
| tree | 7577508e8d90d4421ebbb74aceb9ec9768205e77 /app | |
| parent | 697c91543430592c1edfe95fbbf327ee1923bc54 (diff) | |
chore: log x-request-id in sparkle and authzd
Diffstat (limited to 'app')
| -rw-r--r-- | app/init.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/init.go b/app/init.go index 7b0c386..935c962 100644 --- a/app/init.go +++ b/app/init.go @@ -10,6 +10,7 @@ import ( "github.com/xlgmokha/x/pkg/env" "github.com/xlgmokha/x/pkg/ioc" "github.com/xlgmokha/x/pkg/log" + "github.com/xlgmokha/x/pkg/mapper" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/authzd.git/pkg/rpc" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/cfg" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/controllers/dashboard" @@ -69,4 +70,14 @@ func init() { }) http.DefaultClient = ioc.MustResolve[*http.Client](ioc.Default) + + mapper.Register[*http.Request, log.Fields](func(r *http.Request) log.Fields { + return log.Fields{ + "host": r.URL.Host, + "method": r.Method, + "path": r.URL.Path, + "remote_host": r.RemoteAddr, + "request_id": r.Header.Get("x-request-id"), + } + }) } |
