Documentation
¶
Overview ¶
Package ginadapter mounts routes on a Gin router while recording each route's contract in an goenax.Registry — one declaration, two outputs.
Only this file knows about Gin; goenax's core stays framework-neutral, so this adapter sits beside the Echo and net/http ones without touching it.
Index ¶
- func Routes(e *gin.Engine) []goenax.Route
- type Router
- func (r *Router) DELETE(path string, h gin.HandlerFunc, opts []goenax.Option, mw ...gin.HandlerFunc)
- func (r *Router) Docs(path string, docs http.Handler, mw ...gin.HandlerFunc)
- func (r *Router) GET(path string, h gin.HandlerFunc, opts []goenax.Option, mw ...gin.HandlerFunc)
- func (r *Router) Group(prefix string, mw ...gin.HandlerFunc) *Router
- func (r *Router) Handle(method, path string, h gin.HandlerFunc, opts []goenax.Option, ...)
- func (r *Router) PATCH(path string, h gin.HandlerFunc, opts []goenax.Option, mw ...gin.HandlerFunc)
- func (r *Router) POST(path string, h gin.HandlerFunc, opts []goenax.Option, mw ...gin.HandlerFunc)
- func (r *Router) PUT(path string, h gin.HandlerFunc, opts []goenax.Option, mw ...gin.HandlerFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router wraps a Gin group and a registry. group already carries prefix, so routes are mounted relative to it and recorded with prefix prepended.
func New ¶
New wraps a Gin router (typically the engine) together with the registry and mounts everything under prefix (e.g. "/api"): New(engine, reg, "/api").
Unlike the Echo adapter, pass the *unprefixed* router — New creates the Gin group itself, so the mounted and the recorded paths cannot disagree.
func (*Router) DELETE ¶
func (r *Router) DELETE(path string, h gin.HandlerFunc, opts []goenax.Option, mw ...gin.HandlerFunc)
DELETE mounts and records a DELETE route.
func (*Router) Docs ¶ added in v0.2.0
Docs mounts a goenax.Docs handler at path (the UI) and path+"/openapi.json" (the spec). Gin's default RedirectTrailingSlash sends path+"/" to path. The docs routes are not recorded in the spec and are ignored by Coverage. Pass middleware to guard them, e.g. auth in production:
api.Docs("/docs", goenax.Docs(reg, info), requireStaff)
func (*Router) GET ¶
func (r *Router) GET(path string, h gin.HandlerFunc, opts []goenax.Option, mw ...gin.HandlerFunc)
GET mounts and records a GET route.
func (*Router) Group ¶
func (r *Router) Group(prefix string, mw ...gin.HandlerFunc) *Router
Group mirrors Gin group nesting while extending the recorded prefix.
func (*Router) Handle ¶
func (r *Router) Handle(method, path string, h gin.HandlerFunc, opts []goenax.Option, mw ...gin.HandlerFunc)
Handle mounts a route on Gin (middleware then handler) and records its contract. path is relative to this Router's prefix.
func (*Router) PATCH ¶ added in v0.2.0
func (r *Router) PATCH(path string, h gin.HandlerFunc, opts []goenax.Option, mw ...gin.HandlerFunc)
PATCH mounts and records a PATCH route.
func (*Router) POST ¶
func (r *Router) POST(path string, h gin.HandlerFunc, opts []goenax.Option, mw ...gin.HandlerFunc)
POST mounts and records a POST route.
func (*Router) PUT ¶ added in v0.2.0
func (r *Router) PUT(path string, h gin.HandlerFunc, opts []goenax.Option, mw ...gin.HandlerFunc)
PUT mounts and records a PUT route.