server

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindBody

func BindBody[T any](c *gin.Context) (T, error)

BindBody binds the request body to the given struct. If it fails, an error is returned, that you can directly return from your handler.

func RegisterRoute

func RegisterRoute(g gin.IRoutes, route Route)

RegisterRoute registers a single Route on the given router group. It delegates to gin.IRoutes.Handle using the method and path reported by the route itself, so each handler is self-describing and no central routing table is needed.

func ToGinHandler

func ToGinHandler(h Handler) gin.HandlerFunc

func WithLogging

func WithLogging() gin.HandlerFunc

func WithRequestID

func WithRequestID() gin.HandlerFunc

Types

type HandleFunc

type HandleFunc func(ctx *gin.Context) error

HandleFunc is a function type that satisfies Handler, allowing plain functions to be used as handlers without defining a struct.

type Handler

type Handler interface {
	Handle(ctx *gin.Context) error
}

Handler is the core interface for an HTTP endpoint. Every route handler must implement Handle to process a request and write a response.

type Route

type Route interface {
	Handler

	// Method returns the HTTP method (e.g. "GET", "POST") for this route.
	Method() string
	// Path returns the URL path pattern (e.g. "/v1/tenants/:id") for this route.
	Path() string
}

Route extends Handler with the HTTP method and URL path that the handler should be mounted on. Implementing this interface allows each handler to be self-describing and registered via RegisterRoute without a central routing table.

Jump to

Keyboard shortcuts

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