forked from TrueCloudLab/frostfs-s3-gw
[#318] Log unmatched requests
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
529ec7e0b9
commit
7b86bac6ee
2 changed files with 5 additions and 4 deletions
|
@ -293,7 +293,7 @@ func determineBucketOperation(r *http.Request) string {
|
|||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
return "UnmatchedBucketOperation"
|
||||
}
|
||||
|
||||
func determineObjectOperation(r *http.Request) string {
|
||||
|
@ -357,12 +357,12 @@ func determineObjectOperation(r *http.Request) string {
|
|||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
return "UnmatchedObjectOperation"
|
||||
}
|
||||
|
||||
func determineGeneralOperation(r *http.Request) string {
|
||||
if r.Method == http.MethodGet {
|
||||
return ListBucketsOperation
|
||||
}
|
||||
return ""
|
||||
return "UnmatchedOperation"
|
||||
}
|
||||
|
|
|
@ -148,6 +148,7 @@ func NewRouter(cfg Config) *chi.Mux {
|
|||
defaultRouter := chi.NewRouter()
|
||||
defaultRouter.Mount(fmt.Sprintf("/{%s}", s3middleware.BucketURLPrm), bucketRouter(cfg.Handler, cfg.Log))
|
||||
defaultRouter.Get("/", named("ListBuckets", cfg.Handler.ListBucketsHandler))
|
||||
attachErrorHandler(defaultRouter)
|
||||
|
||||
hr := NewHostBucketRouter("bucket")
|
||||
hr.Default(defaultRouter)
|
||||
|
@ -182,7 +183,7 @@ func errorResponseHandler(w http.ResponseWriter, r *http.Request) {
|
|||
})
|
||||
|
||||
if log := s3middleware.GetReqLog(ctx); log != nil {
|
||||
log.Error(logs.RequestUnmatched, zap.String("method", reqInfo.API))
|
||||
log.Error(logs.RequestUnmatched, zap.String("method", reqInfo.API), zap.String("http method", r.Method), zap.String("url", r.RequestURI))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue