@@ -21,15 +21,15 @@ type contentHandler func(io.Reader, interface{}, *zap.SugaredLogger, string) err
2121
2222// responseUnmarshallers maps MIME types to the corresponding contentHandler functions.
2323var 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 ,
2727}
2828
2929// HandleAPISuccessResponse reads the response body, logs the raw response details, and unmarshals the response based on the content type.
3030func HandleAPISuccessResponse (resp * http.Response , out interface {}, sugar * zap.SugaredLogger ) error {
3131 if resp .Request .Method == "DELETE" {
32- return handleDeleteRequest (resp , sugar )
32+ return successfulDeleteRequest (resp , sugar )
3333 }
3434
3535 bodyBytes , err := io .ReadAll (resp .Body )
@@ -64,7 +64,7 @@ func HandleAPISuccessResponse(resp *http.Response, out interface{}, sugar *zap.S
6464}
6565
6666// 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 {
6868 if resp .StatusCode >= 200 && resp .StatusCode < 300 {
6969 sugar .Info ("Successfully processed DELETE request" , zap .String ("URL" , resp .Request .URL .String ()), zap .Int ("Status Code" , resp .StatusCode ))
7070 return nil
@@ -73,7 +73,7 @@ func handleDeleteRequest(resp *http.Response, sugar *zap.SugaredLogger) error {
7373}
7474
7575// 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 {
7777 decoder := json .NewDecoder (reader )
7878 if err := decoder .Decode (out ); err != nil {
7979 sugar .Error ("JSON Unmarshal error" , zap .Error (err ))
@@ -84,7 +84,7 @@ func unmarshalJSON(reader io.Reader, out interface{}, sugar *zap.SugaredLogger,
8484}
8585
8686// 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 {
8888 decoder := xml .NewDecoder (reader )
8989 if err := decoder .Decode (out ); err != nil {
9090 sugar .Error ("XML Unmarshal error" , zap .Error (err ))
0 commit comments