forked from TrueCloudLab/frostfs-s3-gw
[#306] Simplify namespaces configuration
Resolve ns alias at the beginning of the request just once. Keep in ns map only one default ns key. Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
c4c199defe
commit
37be8851b3
5 changed files with 29 additions and 47 deletions
|
@ -191,6 +191,7 @@ func GetReqLog(ctx context.Context) *zap.Logger {
|
|||
|
||||
type RequestSettings interface {
|
||||
NamespaceHeader() string
|
||||
ResolveNamespaceAlias(string) string
|
||||
}
|
||||
|
||||
func Request(log *zap.Logger, settings RequestSettings) Func {
|
||||
|
@ -207,7 +208,7 @@ func Request(log *zap.Logger, settings RequestSettings) Func {
|
|||
// set request info into context
|
||||
// bucket name and object will be set in reqInfo later (limitation of go-chi)
|
||||
reqInfo := NewReqInfo(w, r, ObjectRequest{})
|
||||
reqInfo.Namespace = r.Header.Get(settings.NamespaceHeader())
|
||||
reqInfo.Namespace = settings.ResolveNamespaceAlias(r.Header.Get(settings.NamespaceHeader()))
|
||||
r = r.WithContext(SetReqInfo(r.Context(), reqInfo))
|
||||
|
||||
// set request id into gRPC meta header
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue