Documentation
¶
Overview ¶
Package gocontroller wires providers and controllers into an existing router. It does not own the HTTP server, request context, or middleware runtime.
Index ¶
- Constants
- func Mount(adapter Adapter, root *Module) error
- type Adapter
- type Controller
- type ControllerDeclaration
- func (d *ControllerDeclaration) CONNECT(path string, middleware ...any) *RouteDeclaration
- func (d *ControllerDeclaration) DELETE(path string, middleware ...any) *RouteDeclaration
- func (d *ControllerDeclaration) GET(path string, middleware ...any) *RouteDeclaration
- func (d *ControllerDeclaration) HEAD(path string, middleware ...any) *RouteDeclaration
- func (d *ControllerDeclaration) MustBind(bindings ...Route) ControllerMetadata
- func (d *ControllerDeclaration) OPTIONS(path string, middleware ...any) *RouteDeclaration
- func (d *ControllerDeclaration) PATCH(path string, middleware ...any) *RouteDeclaration
- func (d *ControllerDeclaration) POST(path string, middleware ...any) *RouteDeclaration
- func (d *ControllerDeclaration) PUT(path string, middleware ...any) *RouteDeclaration
- func (d *ControllerDeclaration) TRACE(path string, middleware ...any) *RouteDeclaration
- func (d *ControllerDeclaration) Use(middleware ...any) *ControllerDeclaration
- func (d *ControllerDeclaration) UseAfter(middleware ...any) *ControllerDeclaration
- func (d *ControllerDeclaration) UseBefore(middleware ...any) *ControllerDeclaration
- type ControllerMetadata
- type MiddlewareGroup
- type Module
- type Route
- func CONNECT(path string, handler any, middleware ...any) Route
- func DELETE(path string, handler any, middleware ...any) Route
- func GET(path string, handler any, middleware ...any) Route
- func HEAD(path string, handler any, middleware ...any) Route
- func OPTIONS(path string, handler any, middleware ...any) Route
- func PATCH(path string, handler any, middleware ...any) Route
- func POST(path string, handler any, middleware ...any) Route
- func PUT(path string, handler any, middleware ...any) Route
- func TRACE(path string, handler any, middleware ...any) Route
- type RouteDeclaration
Constants ¶
const Version = "2.1.0"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adapter ¶
Adapter registers a complete batch of routes on a host router. Implementations must validate all handler and middleware types before registering any routes. Routing, request execution, and errors remain the host framework's concern.
type Controller ¶
type Controller interface {
ControllerMetadata() ControllerMetadata
}
Controller declares routes using bound native framework handler methods. Implement this directly or generate it from @Controller and @Get comments.
type ControllerDeclaration ¶ added in v2.1.0
type ControllerDeclaration struct {
// contains filtered or unexported fields
}
ControllerDeclaration describes a controller for gocontroller-gen. Configure declarations during package initialization, before mounting controllers.
func Controllers ¶ added in v2.1.0
func Controllers(prefix string) *ControllerDeclaration
Controllers declares a prefix for methods marked with var _ = name.GET(...).
func (*ControllerDeclaration) CONNECT ¶ added in v2.1.0
func (d *ControllerDeclaration) CONNECT(path string, middleware ...any) *RouteDeclaration
func (*ControllerDeclaration) DELETE ¶ added in v2.1.0
func (d *ControllerDeclaration) DELETE(path string, middleware ...any) *RouteDeclaration
func (*ControllerDeclaration) GET ¶ added in v2.1.0
func (d *ControllerDeclaration) GET(path string, middleware ...any) *RouteDeclaration
func (*ControllerDeclaration) HEAD ¶ added in v2.1.0
func (d *ControllerDeclaration) HEAD(path string, middleware ...any) *RouteDeclaration
func (*ControllerDeclaration) MustBind ¶ added in v2.1.0
func (d *ControllerDeclaration) MustBind(bindings ...Route) ControllerMetadata
MustBind is used by generated metadata. It binds native handlers without rerunning middleware factories. Stale bindings panic during startup.
func (*ControllerDeclaration) OPTIONS ¶ added in v2.1.0
func (d *ControllerDeclaration) OPTIONS(path string, middleware ...any) *RouteDeclaration
func (*ControllerDeclaration) PATCH ¶ added in v2.1.0
func (d *ControllerDeclaration) PATCH(path string, middleware ...any) *RouteDeclaration
func (*ControllerDeclaration) POST ¶ added in v2.1.0
func (d *ControllerDeclaration) POST(path string, middleware ...any) *RouteDeclaration
func (*ControllerDeclaration) PUT ¶ added in v2.1.0
func (d *ControllerDeclaration) PUT(path string, middleware ...any) *RouteDeclaration
func (*ControllerDeclaration) TRACE ¶ added in v2.1.0
func (d *ControllerDeclaration) TRACE(path string, middleware ...any) *RouteDeclaration
func (*ControllerDeclaration) Use ¶ added in v2.1.0
func (d *ControllerDeclaration) Use(middleware ...any) *ControllerDeclaration
func (*ControllerDeclaration) UseAfter ¶ added in v2.1.0
func (d *ControllerDeclaration) UseAfter(middleware ...any) *ControllerDeclaration
func (*ControllerDeclaration) UseBefore ¶ added in v2.1.0
func (d *ControllerDeclaration) UseBefore(middleware ...any) *ControllerDeclaration
type ControllerMetadata ¶
type MiddlewareGroup ¶ added in v2.1.0
MiddlewareGroup places native middleware before or after the controller handler. After middleware follows the framework's continuation/error rules; it is not a response transformer or a guaranteed finally hook.
func UseAfter ¶ added in v2.1.0
func UseAfter(middleware ...any) MiddlewareGroup
func UseBefore ¶ added in v2.1.0
func UseBefore(middleware ...any) MiddlewareGroup
type Module ¶
type Module struct {
Name string
Prefix string
Providers []any
Controllers []any
Imports []*Module
Middleware []any
}
Module groups controllers and providers. Imported prefixes and middleware nest beneath their parent. Providers are shared singletons within one Mount.
type Route ¶
Route carries native handlers and middleware. Their types are checked by the selected adapter at mount time, before any routes are registered.
type RouteDeclaration ¶ added in v2.1.0
type RouteDeclaration struct {
// contains filtered or unexported fields
}
RouteDeclaration attaches routing information to the following method.
func (*RouteDeclaration) Use ¶ added in v2.1.0
func (r *RouteDeclaration) Use(middleware ...any) *RouteDeclaration
func (*RouteDeclaration) UseAfter ¶ added in v2.1.0
func (r *RouteDeclaration) UseAfter(middleware ...any) *RouteDeclaration
func (*RouteDeclaration) UseBefore ¶ added in v2.1.0
func (r *RouteDeclaration) UseBefore(middleware ...any) *RouteDeclaration