Skip to content

Commit 0bc62ab

Browse files
committed
chore: fix linting issues
1 parent a1d18b4 commit 0bc62ab

3 files changed

Lines changed: 33 additions & 8 deletions

File tree

internal/responsestorerer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ func (r *responseStorer) StoreResponse(
6060
// Remove hop-by-hop headers as per RFC 9111 §3.1
6161
removeHopByHopHeaders(resp)
6262

63-
vary := strings.Join(resp.Header.Values("Vary"), ",") // Join multiple Vary headers into a single string
63+
// Join multiple Vary headers into a single string
64+
vary := strings.Join(resp.Header.Values("Vary"), ",")
6465
varyResolved := maps.Collect(
6566
r.vhn.NormalizeVaryHeader(vary, req.Header),
6667
)

roundtripper_test.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -998,15 +998,23 @@ func Test_transport_Vary_MultipleHeaders(t *testing.T) {
998998
// Request 1: MISS — first request for en-us + 2025-01-01
999999
resp := makeReq("en-us", "2025-01-01")
10001000
testutil.AssertEqual(t, http.StatusOK, resp.StatusCode)
1001-
testutil.AssertEqual(t, internal.CacheStatusMiss.Value, resp.Header.Get(internal.CacheStatusHeader))
1001+
testutil.AssertEqual(
1002+
t,
1003+
internal.CacheStatusMiss.Value,
1004+
resp.Header.Get(internal.CacheStatusHeader),
1005+
)
10021006
body, _ := io.ReadAll(resp.Body)
10031007
_ = resp.Body.Close()
10041008
testutil.AssertEqual(t, "lang=en-us date=2025-01-01", string(body))
10051009

10061010
// Request 2: HIT — same headers
10071011
resp = makeReq("en-us", "2025-01-01")
10081012
testutil.AssertEqual(t, http.StatusOK, resp.StatusCode)
1009-
testutil.AssertEqual(t, internal.CacheStatusHit.Value, resp.Header.Get(internal.CacheStatusHeader))
1013+
testutil.AssertEqual(
1014+
t,
1015+
internal.CacheStatusHit.Value,
1016+
resp.Header.Get(internal.CacheStatusHeader),
1017+
)
10101018
body, _ = io.ReadAll(resp.Body)
10111019
_ = resp.Body.Close()
10121020
testutil.AssertEqual(t, "lang=en-us date=2025-01-01", string(body))
@@ -1015,16 +1023,24 @@ func Test_transport_Vary_MultipleHeaders(t *testing.T) {
10151023
// This is the bug: without the fix, this incorrectly returns a HIT
10161024
resp = makeReq("en-us", "2026-01-01")
10171025
testutil.AssertEqual(t, http.StatusOK, resp.StatusCode)
1018-
testutil.AssertEqual(t, internal.CacheStatusMiss.Value, resp.Header.Get(internal.CacheStatusHeader),
1019-
"X-Compatibility-Date is a Vary header; different value must produce a cache MISS")
1026+
testutil.AssertEqual(
1027+
t,
1028+
internal.CacheStatusMiss.Value,
1029+
resp.Header.Get(internal.CacheStatusHeader),
1030+
"X-Compatibility-Date is a Vary header; different value must produce a cache MISS",
1031+
)
10201032
body, _ = io.ReadAll(resp.Body)
10211033
_ = resp.Body.Close()
10221034
testutil.AssertEqual(t, "lang=en-us date=2026-01-01", string(body))
10231035

10241036
// Request 4: HIT — same as request 3
10251037
resp = makeReq("en-us", "2026-01-01")
10261038
testutil.AssertEqual(t, http.StatusOK, resp.StatusCode)
1027-
testutil.AssertEqual(t, internal.CacheStatusHit.Value, resp.Header.Get(internal.CacheStatusHeader))
1039+
testutil.AssertEqual(
1040+
t,
1041+
internal.CacheStatusHit.Value,
1042+
resp.Header.Get(internal.CacheStatusHeader),
1043+
)
10281044
body, _ = io.ReadAll(resp.Body)
10291045
_ = resp.Body.Close()
10301046
testutil.AssertEqual(t, "lang=en-us date=2026-01-01", string(body))

store/expapi/expapi.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ func retrieve(conn driver.Conn) http.Handler {
9898
if errors.Is(err, driver.ErrNotExist) {
9999
http.Error(w, fmt.Sprintf("key %q not found", key), http.StatusNotFound)
100100
} else {
101-
http.Error(w, fmt.Sprintf("failed to get value for key %q: %v", key, err), http.StatusInternalServerError)
101+
http.Error(
102+
w,
103+
fmt.Sprintf("failed to get value for key %q: %v", key, err),
104+
http.StatusInternalServerError,
105+
)
102106
}
103107
return
104108
}
@@ -121,7 +125,11 @@ func destroy(conn driver.Conn) http.Handler {
121125
if errors.Is(err, driver.ErrNotExist) {
122126
http.Error(w, fmt.Sprintf("key %q not found", key), http.StatusNotFound)
123127
} else {
124-
http.Error(w, fmt.Sprintf("failed to delete value for key %q: %v", key, err), http.StatusInternalServerError)
128+
http.Error(
129+
w,
130+
fmt.Sprintf("failed to delete value for key %q: %v", key, err),
131+
http.StatusInternalServerError,
132+
)
125133
}
126134
return
127135
}

0 commit comments

Comments
 (0)