controllers

package
v0.0.0-...-9aaa355 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeJSON

func DecodeJSON(c *gin.Context, value any) error

DecodeJSON matches field names case-insensitively and rejects duplicate fields and malformed UTF-8 through Go JSON v2. Decoding failures are BadRequest (400); DTO binding-tag violations are NotValid (422). Oversized bodies are rejected with 413 by the HTTP adapters. Errors retain their causes and are returned without writing a response.

func DecodeQuery

func DecodeQuery(c *gin.Context, value any) error

DecodeQuery separates representation errors (400) from constraints (422), without allowing Gin's binding helpers to write a response prematurely.

func DecodeURI

func DecodeURI(c *gin.Context, value any) error

func Error

func Error(ctx *gin.Context, err error)

func Handle

func Handle[T any](handler func(*gin.Context) (T, error), opts ...ResponseOption) gin.HandlerFunc

Handle owns response encoding and error mapping; handlers return typed values.

func NoContent

func NoContent(handler func(*gin.Context) error) gin.HandlerFunc

func ParseRequest

func ParseRequest(ctx *gin.Context, req interface{}) error

Types

type APIAuth

type APIAuth struct {
	Token string
}

APIAuth explicitly enables token authentication, even when Token is empty.

type JWTValidator

type JWTValidator interface {
	Validate(ctx context.Context, token string) error
}

func NewAuth0JWTValidator

func NewAuth0JWTValidator(issuerURL, audience string) (JWTValidator, error)

type ResponseOption

type ResponseOption func(*responseOptions)

func WithStatus

func WithStatus(status int) ResponseOption

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(di ServerDI) (*Server, error)

func (*Server) Engine

func (server *Server) Engine() *gin.Engine

func (*Server) Handler

func (server *Server) Handler() http.Handler

func (*Server) Run

func (server *Server) Run(addr string) error

func (*Server) ServiceName

func (server *Server) ServiceName() string

func (*Server) Shutdown

func (server *Server) Shutdown(ctx context.Context) error

type ServerDI

type ServerDI struct {
	Telemetry     *telemetry.Runtime
	Swagger       bool
	CORS          bool
	APIAuth       *APIAuth
	Validator     *JWTValidator
	ErrorReporter reporter.Reporter
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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