ginx

package
v0.0.0-...-93f578c Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBindingElementMustBePointer = errors.New("binding element must be a pointer")
	ErrBindingElementMustBeStruct  = errors.New("binding element must be a struct")
	ErrUnsupportedFieldType        = errors.New("unsupported field type")
)

Functions

func AbortWithJsonError

func AbortWithJsonError(ctx *gin.Context, code int, err error)

func Close

func Close(ctx context.Context, server *http.Server) error

func EndpointsToMatches

func EndpointsToMatches(base string, endpoints ...[][3]string) map[string]map[string]string

func Fs

func Fs(local string, emFs *embed.FS, emPath string) (http.FileSystem, error)

func JoinPaths

func JoinPaths(absolutePath, relativePath string) string

func MatchOperation

func MatchOperation(base string, endpoints [][3]string, operations ...string) func(ctx *gin.Context) bool

func ShouldBind

func ShouldBind(ctx *gin.Context, obj interface{}, uri, query, body bool) error

func ShouldBindJSON

func ShouldBindJSON(c *gin.Context, obj interface{}) error

func ShouldBindQuery

func ShouldBindQuery(c *gin.Context, obj interface{}) error

func ShouldBindUri

func ShouldBindUri(c *gin.Context, obj interface{}) error

func Start

func Start(ctx context.Context, server *http.Server, closeTimeout time.Duration) error

func Value

func Value[T any](key string, ctx *gin.Context) (*T, bool)

func WithHandler

func WithHandler(h http.Handler) func(ctx *gin.Context)

func WithJson

func WithJson[T any](handler func(ctx *gin.Context) (T, error)) func(ctx *gin.Context)

func WithRecover

func WithRecover(message string, handler func(ctx *gin.Context)) func(ctx *gin.Context)

func WithText

func WithText(handler func(ctx *gin.Context) (string, error)) func(ctx *gin.Context)

Types

type Context

type Context = gin.Context

type DataResponse

type DataResponse[T any] struct {
	Code int `json:"code" default:"0"`
	Data T   `json:"data,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Code    int    `json:"code" default:"1"`
	Error   string `json:"error,omitempty"`
	Message string `json:"message,omitempty"`
}

type TagNameFunc

type TagNameFunc func(f reflect.StructField) string

func (TagNameFunc) Get

func (f TagNameFunc) Get(field reflect.StructField) string

type TagNameGetter

type TagNameGetter interface {
	Get(f reflect.StructField) string
}

type UniverseBinding

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

func (*UniverseBinding) Bind

func (u *UniverseBinding) Bind(c *gin.Context, obj interface{}) error

func (*UniverseBinding) Name

func (u *UniverseBinding) Name() string

Jump to

Keyboard shortcuts

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