feat(06-01): grow router verbs, factories, and guard registry

- Add Post/Put/Patch/Delete on pact.Router and surf Router/Group
- Resolve name:param middleware via RegisterMiddlewareFactory
- Add bouncer.Registry with Guard, CredentialGuard, UnauthorizedWriter
- Re-express jwt as NewJWTGuard without changing Middleware bodies
This commit is contained in:
Jakub Zych
2026-09-19 18:59:12 +02:00
parent ecab09c37a
commit d376b1be2d
9 changed files with 678 additions and 14 deletions

21
bouncer/context_test.go Normal file
View File

@@ -0,0 +1,21 @@
package bouncer
import "testing"
func TestContextCredentialRoundTrip(t *testing.T) {
if _, ok := Credential(t.Context()); ok {
t.Fatal("empty context must have no credential")
}
if _, ok := Credential(nil); ok {
t.Fatal("nil context must have no credential")
}
token := &struct{ Name string }{Name: "parity"}
got, ok := Credential(WithCredential(t.Context(), token))
if !ok || got != token {
t.Fatalf("got %#v ok=%t", got, ok)
}
got, ok = Credential(WithCredential(nil, token))
if !ok || got != token {
t.Fatalf("nil ctx got %#v ok=%t", got, ok)
}
}