forked from TrueCloudLab/frostfs-s3-gw
[#174] Fix object keys with slashes in chi
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
57add29643
commit
6e3595e35b
2 changed files with 13 additions and 19 deletions
|
@ -57,7 +57,6 @@ const HdrAmzRequestID = "x-amz-request-id"
|
|||
|
||||
const (
|
||||
BucketURLPrm = "bucket"
|
||||
ObjectURLPrm = "object"
|
||||
)
|
||||
|
||||
var deploymentID = uuid.Must(uuid.NewRandom())
|
||||
|
@ -238,22 +237,18 @@ func AddBucketName(l *zap.Logger) Func {
|
|||
func AddObjectName(l *zap.Logger) Func {
|
||||
return func(h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
obj := chi.URLParam(r, ObjectURLPrm)
|
||||
ctx := r.Context()
|
||||
reqInfo := GetReqInfo(ctx)
|
||||
|
||||
rctx := chi.RouteContext(ctx)
|
||||
// trim leading slash (always present)
|
||||
obj := rctx.RoutePath[1:]
|
||||
|
||||
object, err := url.PathUnescape(obj)
|
||||
if err != nil {
|
||||
object = obj
|
||||
}
|
||||
prefix, err := url.QueryUnescape(chi.URLParam(r, "prefix"))
|
||||
if err != nil {
|
||||
prefix = chi.URLParam(r, "prefix")
|
||||
}
|
||||
if prefix != "" {
|
||||
object = prefix
|
||||
}
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
reqInfo := GetReqInfo(ctx)
|
||||
reqInfo.ObjectName = object
|
||||
|
||||
reqLogger := reqLogOrDefault(ctx, l)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue