@ -55,8 +55,24 @@ type OnRouteWriteError func(*Route, Context, error) signals.Context
// SigRouteSetup emits after the route has been setup and method handlers have been configured.
var SigRouteSetup = signals . New ( ( OnRouteSetup ) ( nil ) )
// OnRouteSetup accepts the router context and a slice of all Route structs
// derived from the controller as it is processed. Routes will be generated for
// each HTTP method, each special struct method, and any bind routes that were
// configured at runtime.
type OnRouteSetup func ( * Router , [ ] * Route )
// SigManulRouteSetup emits when routes are manually bound using ManualBind().
//
// This is an uncommon trigger since most routes will be configured via their
// controllers but some users may have a need to manually configure a route.
//
// There is no way to differentiate between routes configured via a controller
// and routes configured via ManualBind; use this signal when catching the
// latter.
var SigManualRouteSetup = signals . New ( ( OnManualRouteSetup ) ( nil ) )
type OnManualRouteSetup func ( * Router , * Route )
// SigEachRoute emits for each method handler bound per route.
//
// In Capstan's semantics, routes are defined individually by path *and* by
@ -66,11 +82,27 @@ type OnRouteSetup func(*Router, []*Route)
//
// Capstan uses this signal internally to expose the renderer's convenience
// function for attaching template functions and definitions.
//
// This signal emits for routes configured with ManualBind.
var SigEachRoute = signals . New ( ( OnEachRoute ) ( nil ) )
// OnEachRoute accepts the router context and the Route currently being
// processed. This is triggered before bindRoute is called (meaning the Route is
// not yet attached to any muxer) and before the route is completely configured.
type OnEachRoute func ( * Router , * Route )
// SigRouteComplete emits for each route after the setup, bindRoute, and URL
// mapping has been finalized.
//
// This signal is also emitted when manually bound routes are completed.
var SigRouteComplete = signals . New ( ( OnRouteComplete ) ( nil ) )
// OnRouteComplete accepts the router context and the Route currently processed.
type OnRouteComplete func ( * Router , * Route )
// SigBindRoute emits for each invocation of bindRoute (see funcs.go). This provides preliminary access to the router and muxer state prior to configuration.
var SigBindRoute = signals . New ( ( OnBindRoute ) ( nil ) )
// OnBindRoute accepts as its arguments the router context, the route currently
// being processed, and the assigned muxer.
type OnBindRoute func ( * Router , * Route , chi . Router ) signals . Context