feat(06-03): add raw groups, house middleware, and route:list
- GroupRaw plus sticky raw inheritance and registration-time house-envelope refusal via pact.HasHouseMiddleware - Recover on raw routes writes a bare 500; non-raw keeps the house JSON body - Router.Routes() and surf.RouteListCommand; generated main registers route:list
This commit is contained in:
@@ -42,9 +42,25 @@ type HasMiddlewareFactories interface {
|
||||
MiddlewareFactories() map[string]func(param string) Middleware
|
||||
}
|
||||
|
||||
// HasHouseMiddleware is implemented by plugins that register middleware
|
||||
// tagged as house-envelope/error handling -- refused inside a raw group
|
||||
// (D-16). This is the ONLY way a plugin declares a house-tagged name:
|
||||
// plugins never call a Router.Register* method directly (there is no such
|
||||
// call site anywhere in this codebase -- RegisterMiddleware/
|
||||
// RegisterMiddlewareFactory/RegisterHouseMiddleware are all called
|
||||
// exclusively from surf.Assemble/BuildRouter's plugin loop, the same way
|
||||
// HasMiddleware's Middlewares() map is today). A name present in both
|
||||
// Middlewares() and HouseMiddlewares() (from the same or a different
|
||||
// plugin) fails boot with the existing duplicate-name error, since both are
|
||||
// registered into the same underlying name table.
|
||||
type HasHouseMiddleware interface {
|
||||
HouseMiddlewares() map[string]Middleware
|
||||
}
|
||||
|
||||
// Router is the Laravel-like group builder implemented by surf.
|
||||
type Router interface {
|
||||
Group(prefix string, middleware []string, fn func(Router))
|
||||
GroupRaw(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)
|
||||
@@ -127,6 +143,6 @@ type OptionalMessage interface {
|
||||
//
|
||||
// The kernel type-asserts HasConfig (party, before Register), HasCommands
|
||||
// (generated app main, after Boot), HasMigrations (lagoon migrate), and
|
||||
// HasMiddleware/HasMiddlewareFactories/HasRoutes (surf assemble).
|
||||
// surf.BucketProvider is type-asserted in Assemble (not a pact interface:
|
||||
// pact cannot import surf without a cycle).
|
||||
// HasMiddleware/HasMiddlewareFactories/HasHouseMiddleware/HasRoutes
|
||||
// (surf assemble). surf.BucketProvider is type-asserted in Assemble/
|
||||
// BuildRouter (not a pact interface: pact cannot import surf without a cycle).
|
||||
|
||||
Reference in New Issue
Block a user