ginadapter

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 3 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Routes

func Routes(e *gin.Engine) []goenax.Route

Routes lists the routes registered on a Gin engine as goenax.Route pairs, for use with (*goenax.Registry).Coverage.

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

func New(router gin.IRouter, reg *goenax.Registry, prefix string) *Router

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

func (r *Router) Docs(path string, docs http.Handler, mw ...gin.HandlerFunc)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL