mirror of
https://github.com/minio/minio.git
synced 2025-11-12 14:51:36 -05:00
admin: Add service Set Credentials API (#3580)
This commit is contained in:
committed by
Harshavardhana
parent
20a65981bd
commit
f803bb4b3d
@@ -16,7 +16,10 @@
|
||||
|
||||
package madmin
|
||||
|
||||
import "encoding/xml"
|
||||
import (
|
||||
"encoding/xml"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
/* **** SAMPLE ERROR RESPONSE ****
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
@@ -50,6 +53,29 @@ func (e ErrorResponse) Error() string {
|
||||
return e.Message
|
||||
}
|
||||
|
||||
const (
|
||||
reportIssue = "Please report this issue at https://github.com/minio/minio-go/issues."
|
||||
)
|
||||
|
||||
// httpRespToErrorResponse returns a new encoded ErrorResponse
|
||||
// structure as error.
|
||||
func httpRespToErrorResponse(resp *http.Response) error {
|
||||
if resp == nil {
|
||||
msg := "Response is empty. " + reportIssue
|
||||
return ErrInvalidArgument(msg)
|
||||
}
|
||||
var errResp ErrorResponse
|
||||
// Decode the xml error
|
||||
err := xmlDecoder(resp.Body, &errResp)
|
||||
if err != nil {
|
||||
return ErrorResponse{
|
||||
Code: resp.Status,
|
||||
Message: "Failed to parse server response.",
|
||||
}
|
||||
}
|
||||
return errResp
|
||||
}
|
||||
|
||||
// ErrInvalidArgument - Invalid argument response.
|
||||
func ErrInvalidArgument(message string) error {
|
||||
return ErrorResponse{
|
||||
|
||||
Reference in New Issue
Block a user