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

View File

@@ -36,10 +36,20 @@ type HasMiddleware interface {
Middlewares() map[string]Middleware
}
// HasMiddlewareFactories is implemented by plugins that register
// parameterized middleware ("name:param"), resolved at wrap time.
type HasMiddlewareFactories interface {
MiddlewareFactories() map[string]func(param string) Middleware
}
// Router is the Laravel-like group builder implemented by surf.
type Router interface {
Group(prefix string, middleware []string, fn func(Router))
Get(path string, handler http.HandlerFunc, middleware ...string)
Post(path string, handler http.HandlerFunc, middleware ...string)
Put(path string, handler http.HandlerFunc, middleware ...string)
Patch(path string, handler http.HandlerFunc, middleware ...string)
Delete(path string, handler http.HandlerFunc, middleware ...string)
Where(param, pattern string)
WhereIn(param string, values ...string)
}
@@ -117,4 +127,4 @@ type OptionalMessage interface {
//
// The kernel type-asserts HasConfig (party, before Register), HasCommands
// (generated app main, after Boot), HasMigrations (lagoon migrate), and
// HasMiddleware/HasRoutes (surf assemble).
// HasMiddleware/HasMiddlewareFactories/HasRoutes (surf assemble).