mirror of
https://github.com/minio/minio.git
synced 2025-11-09 05:34:56 -05:00
Add proper requestID for STS errors (#7245)
This commit is contained in:
committed by
kannappanr
parent
396d78352d
commit
8f62935448
@@ -22,12 +22,11 @@ import (
|
||||
)
|
||||
|
||||
// writeSTSErrorRespone writes error headers
|
||||
func writeSTSErrorResponse(w http.ResponseWriter, errorCode STSErrorCode) {
|
||||
stsError := getSTSError(errorCode)
|
||||
func writeSTSErrorResponse(w http.ResponseWriter, err STSError) {
|
||||
// Generate error response.
|
||||
stsErrorResponse := getSTSErrorResponse(stsError)
|
||||
stsErrorResponse := getSTSErrorResponse(err, w.Header().Get(responseRequestIDKey))
|
||||
encodedErrorResponse := encodeResponse(stsErrorResponse)
|
||||
writeResponse(w, stsError.HTTPStatusCode, encodedErrorResponse, mimeXML)
|
||||
writeResponse(w, err.HTTPStatusCode, encodedErrorResponse, mimeXML)
|
||||
}
|
||||
|
||||
// STSError structure
|
||||
@@ -64,9 +63,19 @@ const (
|
||||
ErrSTSInternalError
|
||||
)
|
||||
|
||||
type stsErrorCodeMap map[STSErrorCode]STSError
|
||||
|
||||
func (e stsErrorCodeMap) ToSTSErr(errCode STSErrorCode) STSError {
|
||||
apiErr, ok := e[errCode]
|
||||
if !ok {
|
||||
return e[ErrSTSInternalError]
|
||||
}
|
||||
return apiErr
|
||||
}
|
||||
|
||||
// error code to STSError structure, these fields carry respective
|
||||
// descriptions for all the error responses.
|
||||
var stsErrCodeResponse = map[STSErrorCode]STSError{
|
||||
var stsErrCodes = stsErrorCodeMap{
|
||||
ErrSTSMissingParameter: {
|
||||
Code: "MissingParameter",
|
||||
Description: "A required parameter for the specified action is not supplied.",
|
||||
@@ -109,17 +118,12 @@ var stsErrCodeResponse = map[STSErrorCode]STSError{
|
||||
},
|
||||
}
|
||||
|
||||
// getSTSError provides STS Error for input STS error code.
|
||||
func getSTSError(code STSErrorCode) STSError {
|
||||
return stsErrCodeResponse[code]
|
||||
}
|
||||
|
||||
// getErrorResponse gets in standard error and resource value and
|
||||
// getSTSErrorResponse gets in standard error and
|
||||
// provides a encodable populated response values
|
||||
func getSTSErrorResponse(err STSError) STSErrorResponse {
|
||||
func getSTSErrorResponse(err STSError, requestID string) STSErrorResponse {
|
||||
errRsp := STSErrorResponse{}
|
||||
errRsp.Error.Code = err.Code
|
||||
errRsp.Error.Message = err.Description
|
||||
errRsp.RequestID = "3L137"
|
||||
errRsp.RequestID = requestID
|
||||
return errRsp
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user