Skip to content

Commit aaf9acf

Browse files
committed
removed some functions which literally just wrapped another function and nothing else - 2 of them!
1 parent d30fb5a commit aaf9acf

File tree

5 files changed

+5
-15
lines changed

5 files changed

+5
-15
lines changed

response/error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func HandleAPIErrorResponse(resp *http.Response, sugar *zap.SugaredLogger) *APIE
5757
return apiError
5858
}
5959

60-
mimeType, _ := ParseContentTypeHeader(resp.Header.Get("Content-Type"))
60+
mimeType, _ := parseHeader(resp.Header.Get("Content-Type"))
6161
switch mimeType {
6262
case "application/json":
6363
parseJSONResponse(bodyBytes, apiError)

response/parse.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@ package response
33

44
import "strings"
55

6-
// ParseContentTypeHeader parses the Content-Type header and returns the MIME type and any parameters.
7-
func ParseContentTypeHeader(header string) (string, map[string]string) {
8-
return parseHeader(header)
9-
}
10-
11-
// ParseContentDisposition parses the Content-Disposition header and returns the type and any parameters.
12-
func ParseContentDisposition(header string) (string, map[string]string) {
13-
return parseHeader(header)
14-
}
15-
166
// parseHeader generalizes the parsing of headers like Content-Type and Content-Disposition.
177
// It extracts the main value (e.g., MIME type for Content-Type) and any parameters (like charset).
188
func parseHeader(header string) (string, map[string]string) {

response/success.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func HandleAPISuccessResponse(resp *http.Response, out interface{}, sugar *zap.S
4646
// Use the buffer to create a new io.Reader for unmarshalling
4747
bodyReader := bytes.NewReader(bodyBytes)
4848

49-
mimeType, _ := ParseContentTypeHeader(resp.Header.Get("Content-Type"))
49+
mimeType, _ := parseHeader(resp.Header.Get("Content-Type"))
5050
contentDisposition := resp.Header.Get("Content-Disposition")
5151

5252
if handler, ok := responseUnmarshallers[mimeType]; ok {
@@ -123,7 +123,7 @@ func handleBinaryData(reader io.Reader, sugar *zap.SugaredLogger, out interface{
123123

124124
// Handle Content-Disposition if present
125125
if contentDisposition != "" {
126-
_, params := ParseContentDisposition(contentDisposition)
126+
_, params := parseHeader(contentDisposition)
127127
if filename, ok := params["filename"]; ok {
128128
sugar.Debug("Extracted filename from Content-Disposition", zap.String("filename", filename))
129129
// Additional processing for the filename can be done here if needed

response/t_parse_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TestParseContentTypeHeader(t *testing.T) {
3535

3636
for _, tt := range tests {
3737
t.Run(tt.name, func(t *testing.T) {
38-
gotType, gotParams := ParseContentTypeHeader(tt.header)
38+
gotType, gotParams := parseHeader(tt.header)
3939
if gotType != tt.wantType {
4040
t.Errorf("ParseContentTypeHeader() gotType = %v, want %v", gotType, tt.wantType)
4141
}
@@ -70,7 +70,7 @@ func TestParseContentDisposition(t *testing.T) {
7070

7171
for _, tt := range tests {
7272
t.Run(tt.name, func(t *testing.T) {
73-
gotType, gotParams := ParseContentDisposition(tt.header)
73+
gotType, gotParams := parseHeader(tt.header)
7474
if gotType != tt.wantType {
7575
t.Errorf("ParseContentDisposition() gotType = %v, want %v", gotType, tt.wantType)
7676
}

0 commit comments

Comments
 (0)