[#305] Fix UnknownAPIRequest handling

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-01-17 15:14:51 +03:00 committed by Angira Kekteeva
parent a461feab01
commit 097f745d3e

View file

@ -136,7 +136,7 @@ func WriteErrorResponse(w http.ResponseWriter, reqInfo *ReqInfo, err error) {
func errorResponseHandler(w http.ResponseWriter, r *http.Request) {
desc := fmt.Sprintf("Unknown API request at %s", r.URL.Path)
WriteErrorResponse(w, GetReqInfo(r.Context()), errors.Error{
Code: "XMinioUnknownAPIRequest",
Code: "UnknownAPIRequest",
Description: desc,
HTTPStatusCode: http.StatusBadRequest,
})
@ -235,12 +235,17 @@ func getAPIErrorResponse(info *ReqInfo, err error) ErrorResponse {
desc = e.Description
}
var resource string
if info.URL != nil {
resource = info.URL.Path
}
return ErrorResponse{
Code: code,
Message: desc,
BucketName: info.BucketName,
Key: info.ObjectName,
Resource: info.URL.Path,
Resource: resource,
RequestID: info.RequestID,
HostID: info.DeploymentID,
}