ginx

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbortWithJsonError

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

func AdaptMiddleware

func AdaptMiddleware(middleware ...MiddlewareFunc) gin.HandlerFunc

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 ListenAndAutoShutdown

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

func MatchOperation

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

func ParseError

func ParseError(err error) (code int32, status int32, message string)

func SetDefaultErrorParser

func SetDefaultErrorParser(parser ErrorParser)

func ShouldBindJSON

func ShouldBindJSON(ctx *gin.Context, obj any) error

func ShouldBindQuery

func ShouldBindQuery(ctx *gin.Context, obj any) error

func ShouldBindUri

func ShouldBindUri(ctx *gin.Context, obj any) error

func ShouldUniverseBind

func ShouldUniverseBind(ctx *gin.Context, obj any, uri, query, body bool) error

func ShouldUniverseBindQuery

func ShouldUniverseBindQuery(ctx *gin.Context, obj any) error

func ShouldUniverseBindUri

func ShouldUniverseBindUri(ctx *gin.Context, obj any) error

func Start

func Start(server *http.Server) error

func Value

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

func WithFormFileBytes

func WithFormFileBytes[T any](handler func(ctx *gin.Context, file []byte, filename string) (*T, error), options ...WithFormOption) gin.HandlerFunc

func WithFormFileReader

func WithFormFileReader[T any](handler func(ctx *gin.Context, file io.Reader, filename string) (*T, error), options ...WithFormOption) gin.HandlerFunc

func WithHandler

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

func WithJson

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

func WithRecover

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

func WithText

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

Types

type Context

type Context = gin.Context

type DataResponse

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

type ErrorParser

type ErrorParser func(error) (int32, int32, string)

type ErrorResponse

type ErrorResponse struct {
	Success bool   `json:"success" default:"false"`
	Code    int    `json:"code" default:"0"`
	Error   string `json:"error,omitempty"`
	Message string `json:"message,omitempty"`
}

type HandlerFunc

type HandlerFunc func(ctx *gin.Context) error

type MiddlewareFunc

type MiddlewareFunc func(next HandlerFunc) HandlerFunc

func MiddlewareChain

func MiddlewareChain(middlewares ...MiddlewareFunc) MiddlewareFunc

type WithFormOption

type WithFormOption func(*WithFormOptions)

func WithFormAllowExtensions

func WithFormAllowExtensions(extensions ...string) WithFormOption

func WithFormFileKey

func WithFormFileKey(key string) WithFormOption

func WithFormMaxSize

func WithFormMaxSize(maxSize int64) WithFormOption

type WithFormOptions

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

Jump to

Keyboard shortcuts

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