Documentation
¶
Overview ¶
Package routecontracts registers HTTP routes and OpenAPI operations together.
It is intentionally router-neutral and uses only the common method registration shape already provided by ports.HTTPRouter. PATCH support is detected with a local optional interface so stable router interfaces are not widened.
Index ¶
- type CoverageError
- type Registry
- func (r *Registry) Delete(pattern string, operation specs.Operation, handler http.Handler, ...) error
- func (r *Registry) Get(pattern string, operation specs.Operation, handler http.Handler, ...) error
- func (r *Registry) Patch(pattern string, operation specs.Operation, handler http.Handler, ...) error
- func (r *Registry) Post(pattern string, operation specs.Operation, handler http.Handler, ...) error
- func (r *Registry) Put(pattern string, operation specs.Operation, handler http.Handler, ...) error
- func (r *Registry) Register(route Route) error
- func (r *Registry) Routes() []Route
- func (r *Registry) Validate() error
- type Route
- type Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CoverageError ¶
type CoverageError struct {
Problems []string
}
CoverageError reports route contract validation failures.
func (*CoverageError) Error ¶
func (e *CoverageError) Error() string
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry registers routes and keeps route contract metadata for validation.
func NewRegistry ¶
NewRegistry creates a route contract registry.
func (*Registry) Delete ¶
func (r *Registry) Delete(pattern string, operation specs.Operation, handler http.Handler, middleware ...func(http.Handler) http.Handler) error
Delete registers a DELETE route contract.
func (*Registry) Get ¶
func (r *Registry) Get(pattern string, operation specs.Operation, handler http.Handler, middleware ...func(http.Handler) http.Handler) error
Get registers a GET route contract.
func (*Registry) Patch ¶
func (r *Registry) Patch(pattern string, operation specs.Operation, handler http.Handler, middleware ...func(http.Handler) http.Handler) error
Patch registers a PATCH route contract when the router supports PATCH.
func (*Registry) Post ¶
func (r *Registry) Post(pattern string, operation specs.Operation, handler http.Handler, middleware ...func(http.Handler) http.Handler) error
Post registers a POST route contract.
func (*Registry) Put ¶
func (r *Registry) Put(pattern string, operation specs.Operation, handler http.Handler, middleware ...func(http.Handler) http.Handler) error
Put registers a PUT route contract.
type Route ¶
type Route struct {
Method string
Pattern string
Handler http.Handler
Middleware []func(http.Handler) http.Handler
Operation specs.Operation
}
Route describes one runtime route and its OpenAPI operation.
type Router ¶
type Router interface {
Get(pattern string, h http.HandlerFunc)
Post(pattern string, h http.HandlerFunc)
Put(pattern string, h http.HandlerFunc)
Delete(pattern string, h http.HandlerFunc)
}
Router is the route registration surface required by this package.