Skip to content

Commit

Permalink
fix: middleware overwrite metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
SpectatorNan committed Nov 9, 2023
1 parent 5e9c300 commit b15115e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#### Go zero api server

```shell

```go

import "github.com/SpectatorNan/go-zero-i18n/goi18nx"
Expand Down
3 changes: 1 addition & 2 deletions goi18nx/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ func withRequest(r *http.Request, bundle *i18n2.Bundle) *http.Request {
accept := r.Header.Get(defaultLangHeaderKey)
localizer := i18n2.NewLocalizer(bundle, accept)
ctx := setLocalizer(r.Context(), localizer)
md := metadata.New(map[string]string{defaultLangHeaderKey: accept})
ctx = metadata.NewOutgoingContext(ctx, md)
ctx = metadata.AppendToOutgoingContext(ctx, defaultLangHeaderKey, accept)
return r.WithContext(ctx)
}

Expand Down

0 comments on commit b15115e

Please sign in to comment.