@@ -21,15 +21,15 @@ type contentHandler func(io.Reader, interface{}, *zap.SugaredLogger, string) err
21
21
22
22
// responseUnmarshallers maps MIME types to the corresponding contentHandler functions.
23
23
var responseUnmarshallers = map [string ]contentHandler {
24
- "application/json" : unmarshalJSON ,
25
- "application/xml" : unmarshalXML ,
26
- "text/xml" : unmarshalXML ,
24
+ "application/json" : handlerUnmarshalJSON ,
25
+ "application/xml" : handlerUnmarshalXML ,
26
+ "text/xml" : handlerUnmarshalXML ,
27
27
}
28
28
29
29
// HandleAPISuccessResponse reads the response body, logs the raw response details, and unmarshals the response based on the content type.
30
30
func HandleAPISuccessResponse (resp * http.Response , out interface {}, sugar * zap.SugaredLogger ) error {
31
31
if resp .Request .Method == "DELETE" {
32
- return handleDeleteRequest (resp , sugar )
32
+ return successfulDeleteRequest (resp , sugar )
33
33
}
34
34
35
35
bodyBytes , err := io .ReadAll (resp .Body )
@@ -64,7 +64,7 @@ func HandleAPISuccessResponse(resp *http.Response, out interface{}, sugar *zap.S
64
64
}
65
65
66
66
// handleDeleteRequest handles the special case for DELETE requests, where a successful response might not contain a body.
67
- func handleDeleteRequest (resp * http.Response , sugar * zap.SugaredLogger ) error {
67
+ func successfulDeleteRequest (resp * http.Response , sugar * zap.SugaredLogger ) error {
68
68
if resp .StatusCode >= 200 && resp .StatusCode < 300 {
69
69
sugar .Info ("Successfully processed DELETE request" , zap .String ("URL" , resp .Request .URL .String ()), zap .Int ("Status Code" , resp .StatusCode ))
70
70
return nil
@@ -73,7 +73,7 @@ func handleDeleteRequest(resp *http.Response, sugar *zap.SugaredLogger) error {
73
73
}
74
74
75
75
// unmarshalJSON unmarshals JSON content from an io.Reader into the provided output structure.
76
- func unmarshalJSON (reader io.Reader , out interface {}, sugar * zap.SugaredLogger , mimeType string ) error {
76
+ func handlerUnmarshalJSON (reader io.Reader , out interface {}, sugar * zap.SugaredLogger , mimeType string ) error {
77
77
decoder := json .NewDecoder (reader )
78
78
if err := decoder .Decode (out ); err != nil {
79
79
sugar .Error ("JSON Unmarshal error" , zap .Error (err ))
@@ -84,7 +84,7 @@ func unmarshalJSON(reader io.Reader, out interface{}, sugar *zap.SugaredLogger,
84
84
}
85
85
86
86
// unmarshalXML unmarshals XML content from an io.Reader into the provided output structure.
87
- func unmarshalXML (reader io.Reader , out interface {}, sugar * zap.SugaredLogger , mimeType string ) error {
87
+ func handlerUnmarshalXML (reader io.Reader , out interface {}, sugar * zap.SugaredLogger , mimeType string ) error {
88
88
decoder := xml .NewDecoder (reader )
89
89
if err := decoder .Decode (out ); err != nil {
90
90
sugar .Error ("XML Unmarshal error" , zap .Error (err ))
0 commit comments