Skip to content

Commit c1c0ee9

Browse files
authored
feat(core): disable vary (#28)
* feat(core): disable vary * feat(bump): version v0.0.13 * fix(ci): lint
1 parent b154cc2 commit c1c0ee9

File tree

21 files changed

+44
-39
lines changed

21 files changed

+44
-39
lines changed

.github/workflows/static.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
workflow_dispatch:
66

77
env:
8-
GO_VERSION: '1.22'
8+
GO_VERSION: '1.24'
99

1010
jobs:
1111
static-validation:
@@ -64,4 +64,4 @@ jobs:
6464
with:
6565
working-directory: ${{ matrix.submodules }}
6666
- name: unit tests
67-
run: go test -v -race ./${{ matrix.submodules }}
67+
run: go test -v -race ./${{ matrix.submodules }}

badger/caddy/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ go 1.22.1
44

55
require (
66
github.com/caddyserver/caddy/v2 v2.8.4
7-
github.com/darkweak/storages/badger v0.0.12
8-
github.com/darkweak/storages/core v0.0.12
7+
github.com/darkweak/storages/badger v0.0.13
8+
github.com/darkweak/storages/core v0.0.13
99
)
1010

1111
require (

badger/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.22.1
44

55
require (
66
dario.cat/mergo v1.0.1
7-
github.com/darkweak/storages/core v0.0.12
7+
github.com/darkweak/storages/core v0.0.13
88
github.com/dgraph-io/badger/v3 v3.2103.5
99
github.com/pierrec/lz4/v4 v4.1.22
1010
go.uber.org/zap v1.27.0

core/core.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"strings"
1010
"time"
1111

12-
lz4 "github.com/pierrec/lz4/v4"
12+
"github.com/pierrec/lz4/v4"
1313
"google.golang.org/protobuf/proto"
1414
"google.golang.org/protobuf/types/known/timestamppb"
1515
)
@@ -41,7 +41,10 @@ type CacheProvider struct {
4141
Configuration interface{} `json:"configuration" yaml:"configuration"`
4242
}
4343

44-
const MappingKeyPrefix = "IDX_"
44+
const (
45+
DISABLE_VARY_CTX = "storages_bypass_vary"
46+
MappingKeyPrefix = "IDX_"
47+
)
4548

4649
func DecodeMapping(item []byte) (*StorageMapper, error) {
4750
mapping := &StorageMapper{}
@@ -63,11 +66,13 @@ func MappingElection(provider Storer, item []byte, req *http.Request, validator
6366
for keyName, keyItem := range mapping.GetMapping() {
6467
valid := true
6568

66-
for hname, hval := range keyItem.GetVariedHeaders() {
67-
if req.Header.Get(hname) != strings.Join(hval.GetHeaderValue(), ", ") {
68-
valid = false
69+
if req.Context().Value(DISABLE_VARY_CTX) == nil || !req.Context().Value(DISABLE_VARY_CTX).(bool) {
70+
for hname, hval := range keyItem.GetVariedHeaders() {
71+
if req.Header.Get(hname) != strings.Join(hval.GetHeaderValue(), ", ") {
72+
valid = false
6973

70-
break
74+
break
75+
}
7176
}
7277
}
7378

etcd/caddy/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ go 1.22.1
44

55
require (
66
github.com/caddyserver/caddy/v2 v2.8.4
7-
github.com/darkweak/storages/core v0.0.12
8-
github.com/darkweak/storages/etcd v0.0.12
7+
github.com/darkweak/storages/core v0.0.13
8+
github.com/darkweak/storages/etcd v0.0.13
99
)
1010

1111
require (

etcd/etcd.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"time"
1313

1414
"github.com/darkweak/storages/core"
15-
lz4 "github.com/pierrec/lz4/v4"
15+
"github.com/pierrec/lz4/v4"
1616
clientv3 "go.etcd.io/etcd/client/v3"
1717
"go.uber.org/zap"
1818
"google.golang.org/grpc/connectivity"
@@ -85,9 +85,9 @@ func (provider *Etcd) Name() string {
8585
func (provider *Etcd) Uuid() string {
8686
return fmt.Sprintf(
8787
"%s-%s-%s-%s",
88-
strings.Join(provider.Endpoints(), ","),
89-
provider.Username,
90-
provider.Password,
88+
strings.Join(provider.Client.Endpoints(), ","),
89+
provider.Client.Username,
90+
provider.Client.Password,
9191
provider.stale,
9292
)
9393
}

etcd/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.22.1
55
replace github.com/darkweak/storages/core => ../core
66

77
require (
8-
github.com/darkweak/storages/core v0.0.12
8+
github.com/darkweak/storages/core v0.0.13
99
github.com/pierrec/lz4/v4 v4.1.22
1010
go.etcd.io/etcd/client/v3 v3.5.18
1111
go.uber.org/zap v1.27.0

go-redis/caddy/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ go 1.22.1
44

55
require (
66
github.com/caddyserver/caddy/v2 v2.8.4
7-
github.com/darkweak/storages/core v0.0.12
8-
github.com/darkweak/storages/go-redis v0.0.12
7+
github.com/darkweak/storages/core v0.0.13
8+
github.com/darkweak/storages/go-redis v0.0.13
99
)
1010

1111
require (

go-redis/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.22.1
55
replace github.com/darkweak/storages/core => ../core
66

77
require (
8-
github.com/darkweak/storages/core v0.0.12
8+
github.com/darkweak/storages/core v0.0.13
99
github.com/pierrec/lz4/v4 v4.1.22
1010
github.com/redis/go-redis/v9 v9.7.1
1111
go.uber.org/zap v1.27.0

nats/caddy/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ go 1.22.1
44

55
require (
66
github.com/caddyserver/caddy/v2 v2.8.4
7-
github.com/darkweak/storages/core v0.0.12
8-
github.com/darkweak/storages/nats v0.0.12
7+
github.com/darkweak/storages/core v0.0.13
8+
github.com/darkweak/storages/nats v0.0.13
99
)
1010

1111
require (

0 commit comments

Comments
 (0)