diff options
| author | mo khan <mo@mokhan.ca> | 2025-04-24 16:51:54 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-04-24 16:51:54 -0600 |
| commit | 072a554f7fa5c4ce1d7e5bcc389ffb3e4640d198 (patch) | |
| tree | e77201c277871383f8275f52b84c1850ba0c42ae /pkg/test/http.go | |
| parent | 378881c9869124c888817af4fb1dae6a4a93a4f6 (diff) | |
feat: add middleware to require a logged in user
Diffstat (limited to 'pkg/test/http.go')
| -rw-r--r-- | pkg/test/http.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/pkg/test/http.go b/pkg/test/http.go index 54712f1..280aef6 100644 --- a/pkg/test/http.go +++ b/pkg/test/http.go @@ -7,6 +7,7 @@ import ( "net/http" "net/http/httptest" + xcontext "github.com/xlgmokha/x/pkg/context" "github.com/xlgmokha/x/pkg/serde" "github.com/xlgmokha/x/pkg/x" ) @@ -55,6 +56,10 @@ func WithContext(ctx context.Context) RequestOption { } } +func WithContextKeyValue[T any](ctx context.Context, key xcontext.Key[T], item T) RequestOption { + return WithContext(key.With(ctx, item)) +} + func WithCookie(cookie *http.Cookie) RequestOption { return func(r *http.Request) *http.Request { r.AddCookie(cookie) |
