diff --git a/README.md b/README.md index a141422..c18dcce 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ #### Go zero api server -```shell + ```go import "github.com/SpectatorNan/go-zero-i18n/goi18nx" diff --git a/goi18nx/cache.go b/goi18nx/cache.go index a94d6d2..2ddacb6 100644 --- a/goi18nx/cache.go +++ b/goi18nx/cache.go @@ -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) }