mirror of
https://github.com/distribution/distribution.git
synced 2025-09-09 18:59:40 +00:00
refactor: replace map iteration with maps.Copy/Clone
Signed-off-by: whosehang <whosehang@outlook.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package auth
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
@@ -38,9 +39,7 @@ func (w *testAuthenticationWrapper) ServeHTTP(rw http.ResponseWriter, r *http.Re
|
||||
auth := r.Header.Get("Authorization")
|
||||
if auth == "" || !w.authCheck(auth) {
|
||||
h := rw.Header()
|
||||
for k, values := range w.headers {
|
||||
h[k] = values
|
||||
}
|
||||
maps.Copy(h, w.headers)
|
||||
rw.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package dcontext
|
||||
|
||||
import (
|
||||
"context"
|
||||
"maps"
|
||||
"sync"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -52,9 +53,7 @@ type stringMapContext struct {
|
||||
// supports string keys.
|
||||
func WithValues(ctx context.Context, m map[string]interface{}) context.Context {
|
||||
mo := make(map[string]interface{}, len(m)) // make our own copy.
|
||||
for k, v := range m {
|
||||
mo[k] = v
|
||||
}
|
||||
maps.Copy(mo, m)
|
||||
|
||||
return stringMapContext{
|
||||
Context: ctx,
|
||||
|
Reference in New Issue
Block a user