diff --git a/constants.go b/constants.go index 9799c0ef9895280165710af804249d704d15b14e..e0dbdd375c7a569ff68e1cd2663065d9c8c104b3 100644 --- a/constants.go +++ b/constants.go @@ -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" diff --git a/flake.lock b/flake.lock index fd83cb26545c4e45e58905b3f5f36d93bf92f561..a0e8464590781cc6a26cd19813def747a5ff32d1 100644 --- a/flake.lock +++ b/flake.lock @@ -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": { diff --git a/go.mod b/go.mod index 769044e2fea79baecb80d4ed28af41a2a5d4ee66..3c9d4a23212803775d0b2450f8c3e38d85312245 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 6a220c1f39c9e425955cb55eea15dbb3ec7a28ee..473b8978e5a680779a851caf71eeaa4dec0f3a61 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ 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= diff --git a/http-handler.go b/http-handler.go index 75dba800f0cd556a1b56819c9c51694ab024a8a3..abc3c3e0ffc97acbfee97ff8e77a58b316d28f12 100644 --- a/http-handler.go +++ b/http-handler.go @@ -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) }) diff --git a/http-handler_test.go b/http-handler_test.go index 070f3a525da400f9d1f65dd8c4544c67e92f1007..3a92e37c3d8ac59b651f6c912e708ba3ac73a5b8 100644 --- a/http-handler_test.go +++ b/http-handler_test.go @@ -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 diff --git a/nix/config/release.nix b/nix/config/release.nix index bf21d9b46ff2baf29ec69c6d89ce776d807f38de..f239d51610d37dff51ddadcbf7aea3172518943b 100644 --- a/nix/config/release.nix +++ b/nix/config/release.nix @@ -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 +}