Skip to content
Snippets Groups Projects
Verified Commit f2c175ca authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

fix: context constants must be public

parent e9bed6ad
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@ package configuration
type ContextKey string
const fileName = "config"
const contextKey = ContextKey("config")
const ContextConfigKey = ContextKey("config")
const envTagKey = "env"
const flagTagKey = "flag"
......@@ -72,11 +72,11 @@
},
"nixpkgsUnstable": {
"locked": {
"lastModified": 1727348695,
"narHash": "sha256-J+PeFKSDV+pHL7ukkfpVzCOO7mBSrrpJ3svwBFABbhI=",
"lastModified": 1730200266,
"narHash": "sha256-l253w0XMT8nWHGXuXqyiIC/bMvh1VRszGXgdpQlfhvU=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "1925c603f17fc89f4c8f6bf6f631a802ad85d784",
"rev": "807e9154dcb16384b1b765ebe9cd2bba2ac287fd",
"type": "github"
},
"original": {
......@@ -88,11 +88,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1727397532,
"narHash": "sha256-pojbL/qteElw/nIXlN8kmHn/w6PQbEHr7Iz+WOXs0EM=",
"lastModified": 1730137625,
"narHash": "sha256-9z8oOgFZiaguj+bbi3k4QhAD6JabWrnv7fscC/mt0KE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "f65141456289e81ea0d5a05af8898333cab5c53d",
"rev": "64b80bfb316b57cdb8919a9110ef63393d74382a",
"type": "github"
},
"original": {
......
......@@ -15,16 +15,16 @@ require (
gitlab.schukai.com/oss/libraries/go/network/http-negotiation.git v1.3.4
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder.git v0.9.5
gitlab.schukai.com/oss/libraries/go/utilities/watch.git v0.4.2
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
gopkg.in/yaml.v3 v3.0.1
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/sys v0.26.0 // indirect
)
replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.16
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
......@@ -32,10 +32,10 @@ gitlab.schukai.com/oss/libraries/go/utilities/pathfinder.git v0.9.5 h1:PiDmw3O3U
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder.git v0.9.5/go.mod h1:HwXjaFUAxLv+qTN63xrPBO5DEVGuZNF859t29bhTsFQ=
gitlab.schukai.com/oss/libraries/go/utilities/watch.git v0.4.2 h1:PoX7Cxmclttb5lIrrHZ5QvIjN5MAaaWvReFU972RgpM=
gitlab.schukai.com/oss/libraries/go/utilities/watch.git v0.4.2/go.mod h1:7Rv8r5eVw5FDRp/K3KlDmjNMrdj7JA7eC3o6s7JBcHU=
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk=
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
......
......@@ -10,12 +10,12 @@ import (
"net/http"
)
// ContextKey is the key used to store the configuration in the request context
// ContextConfigKey is the key used to store the configuration in the request context
// This is used by the middleware
func (s *Settings[C]) Middleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
ctx = context.WithValue(ctx, contextKey, s.config)
ctx = context.WithValue(ctx, ContextConfigKey, s.config)
r = r.WithContext(ctx)
next.ServeHTTP(w, r)
})
......
......@@ -53,7 +53,7 @@ func TestConfigurationMiddleware(t *testing.T) {
}
nextHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
val := r.Context().Value(ContextKey("config"))
val := r.Context().Value(ContextConfigKey)
if val == nil {
t.Error("config not present")
return
......
......@@ -2,8 +2,8 @@
# this file is generated by nix/scripts/init-project.nix
# please don't edit it manually
version = "v1.22.8";
commit = "3cdb9489349e5b6931e0974664ed6a5fbf186c72";
version = "1.22.8";
commit = "e9bed6ad8a7dfb23781debb49d06317660ec09f4";
projectURL = "https://gitlab.schukai.com/oss/configuration";
name = "configuration";
mnemonic = "configuration";
......@@ -12,4 +12,4 @@
# this file is generated by nix/scripts/init-project.nix
# please don't edit it manually
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment