Skip to content

Commit c8c9707

Browse files
committed
removed unnecessary comments
1 parent aaf9acf commit c8c9707

File tree

3 files changed

+2
-10
lines changed

3 files changed

+2
-10
lines changed

response/error.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,15 @@ type APIError struct {
2727

2828
// Error returns a string representation of the APIError, making it compatible with the error interface.
2929
func (e *APIError) Error() string {
30-
// Attempt to marshal the APIError instance into a JSON string.
3130
data, err := json.Marshal(e)
3231
if err == nil {
3332
return string(data)
3433
}
3534

36-
// Use the standard HTTP status text as the error message if 'Message' field is empty.
3735
if e.Message == "" {
3836
e.Message = http.StatusText(e.StatusCode)
3937
}
4038

41-
// Fallback to a simpler error message format if JSON marshaling fails.
4239
return fmt.Sprintf("API Error: StatusCode=%d, Message=%s", e.StatusCode, e.Message)
4340
}
4441

@@ -179,7 +176,6 @@ func parseHTMLResponse(bodyBytes []byte, apiError *APIError) {
179176

180177
parse(doc)
181178

182-
// Concatenate all accumulated messages and links with a separator.
183179
if len(messages) > 0 {
184180
apiError.Message = strings.Join(messages, "; ")
185181
} else {

response/parse.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import "strings"
66
// parseHeader generalizes the parsing of headers like Content-Type and Content-Disposition.
77
// It extracts the main value (e.g., MIME type for Content-Type) and any parameters (like charset).
88
func parseHeader(header string) (string, map[string]string) {
9-
parts := strings.SplitN(header, ";", 2) // Split into main value and parameters
9+
parts := strings.SplitN(header, ";", 2)
1010
mainValue := strings.TrimSpace(parts[0])
1111

1212
params := make(map[string]string)
13-
if len(parts) > 1 { // Check if there are parameters
13+
if len(parts) > 1 {
1414
for _, part := range strings.Split(parts[1], ";") {
1515
kv := strings.SplitN(part, "=", 2)
1616
if len(kv) == 2 {

response/success.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,16 @@ func HandleAPISuccessResponse(resp *http.Response, out interface{}, sugar *zap.S
3232
return handleDeleteRequest(resp, sugar)
3333
}
3434

35-
// Read the response body into a buffer
3635
bodyBytes, err := io.ReadAll(resp.Body)
3736
if err != nil {
3837
sugar.Error("Failed to read response body", zap.Error(err))
3938
return err
4039
}
4140

42-
// After reading, reset resp.Body so it can be read again.
4341
sugar.Debug("HTTP Response Headers", zap.Any("Headers", resp.Header))
4442
sugar.Debug("Raw HTTP Response", zap.String("Body", string(bodyBytes)))
4543

46-
// Use the buffer to create a new io.Reader for unmarshalling
4744
bodyReader := bytes.NewReader(bodyBytes)
48-
4945
mimeType, _ := parseHeader(resp.Header.Get("Content-Type"))
5046
contentDisposition := resp.Header.Get("Content-Disposition")
5147

0 commit comments

Comments
 (0)