Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/basecamp/thruster

go 1.25.6
go 1.26

require (
github.com/klauspost/compress v1.18.2
Expand Down
5 changes: 2 additions & 3 deletions internal/cacheable_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/gob"
"io"
"log/slog"
"maps"
"net/http"
"regexp"
"strconv"
Expand Down Expand Up @@ -149,9 +150,7 @@ func (c *CacheableResponse) wasNotModified(r *http.Request) bool {
}

func (c *CacheableResponse) copyHeaders(w http.ResponseWriter, wasHit bool, statusCode int) {
for k, v := range c.HttpHeader {
w.Header()[k] = v
}
maps.Copy(w.Header(), c.HttpHeader)

if wasHit {
w.Header().Set("X-Cache", "hit")
Expand Down
4 changes: 2 additions & 2 deletions internal/compression_guard_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func hasUserSpecificResponseHeaders(h http.Header) bool {
}

cacheControl := strings.ToLower(h.Get("Cache-Control"))
for _, directive := range strings.Split(cacheControl, ",") {
for directive := range strings.SplitSeq(cacheControl, ",") {
dir := strings.TrimSpace(directive)
// Strip any value (e.g. private="Set-Cookie") before comparison.
dirName := strings.SplitN(dir, "=", 2)[0]
Expand All @@ -70,7 +70,7 @@ func hasUserSpecificResponseHeaders(h http.Header) bool {
}

vary := h.Get("Vary")
for _, token := range strings.Split(vary, ",") {
for token := range strings.SplitSeq(vary, ",") {
if strings.EqualFold(strings.TrimSpace(token), "cookie") {
return true
}
Expand Down
2 changes: 1 addition & 1 deletion internal/memory_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (c *MemoryCache) evictOldestItem() {
//
// If we find an expired item while looking, that's a better choice to evict,
// so we can choose it immediately.
for i := 0; i < 5; i++ {
for range 5 {
index := rand.Intn(len(c.keys))
key := c.keys[index]
v := c.items[key]
Expand Down
2 changes: 1 addition & 1 deletion internal/memory_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestMemoryCache_items_are_evicted_to_make_space(t *testing.T) {
maxCacheSize := 10 * KB
c := NewMemoryCache(maxCacheSize, 1*KB)

for i := CacheKey(0); i < 20; i++ {
for i := range CacheKey(20) {
payload := bytes.Repeat([]byte{byte(i)}, 1*KB)
c.Set(i, payload, time.Now().Add(1*time.Hour))

Expand Down
Loading