pgin

package
v1.1.47 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Default

func Default(opts ...gin.OptionFunc) *gin.Engine

func ErrorReturnHandler

func ErrorReturnHandler(fn errorReturnHandler) gin.HandlerFunc

func GetSession

func GetSession(c *gin.Context) sessions.Session

func GetSessionByKey

func GetSessionByKey(c *gin.Context, key string) sessions.Session

func LoggerMiddleware

func LoggerMiddleware(loggers ...plog.Logger) gin.HandlerFunc

func LoggingRequest

func LoggingRequest(header bool) gin.HandlerFunc

func MountHandler added in v1.1.47

func MountHandler[MH ModelHandler[R], R any]() gin.HandlerFunc

func NewServerHandler

func NewServerHandler() *gin.Engine

func NewServerHandlerWithOptions

func NewServerHandlerWithOptions(opts ...Option) *gin.Engine

func NewSession

func NewSession(key string, opt StoreOption) gin.HandlerFunc

func NewStandardServerHandler

func NewStandardServerHandler() *gin.Engine

func ParseRequestParams

func ParseRequestParams(c *gin.Context, obj any) (err error)

func RequestHandler

func RequestHandler[Q any](fn requestHandler[Q]) gin.HandlerFunc

func RequestResponseHandler

func RequestResponseHandler[Q any, P any](fn requestResponseHandler[Q, P]) gin.HandlerFunc

func RequestWithErrorHandler

func RequestWithErrorHandler[Q any](fn requestWithErrorHandler[Q]) gin.HandlerFunc

func ResponseHandler

func ResponseHandler[P any](fn responseHandler[P]) gin.HandlerFunc

func ReturnError

func ReturnError(c *gin.Context, code int, message any)

func ReturnSuccess

func ReturnSuccess(c *gin.Context, data any)

func ReuseBody

func ReuseBody() gin.HandlerFunc

func ValidateRequestParams

func ValidateRequestParams(obj any) (err error)

Types

type CookieStore

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

func InitCookieStore

func InitCookieStore(keyPairs ...[]byte) *CookieStore

func (*CookieStore) GetStore

func (c *CookieStore) GetStore() sessions.Store

type Error

type Error interface {
	error

	Code() int
	Cause() error
	Message() string
}

func PackError

func PackError(code int, vals ...any) Error

type MemoryStore

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

func InitMemStore

func InitMemStore(keyPairs ...[]byte) *MemoryStore

func (*MemoryStore) GetStore

func (m *MemoryStore) GetStore() sessions.Store

type ModelHandler added in v1.1.47

type ModelHandler[R any] interface {
	Handle(c *gin.Context) (resp *R, err error)
}

type Option

type Option func(*gin.Engine)

func WithHiddenRoutesLog

func WithHiddenRoutesLog() Option

func WithLoggingRequest

func WithLoggingRequest(header bool) Option

func WithMiddlewares

func WithMiddlewares(middlewares ...gin.HandlerFunc) Option

func WithReuseBody

func WithReuseBody() Option

func WithRouters

func WithRouters(basePath string, routers ...Router) Option

func WithServiceName

func WithServiceName(name string) Option

type RedisStore

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

func InitRedisStore

func InitRedisStore(pool *redis.Pool, keyPairs ...[]byte) *RedisStore

func (*RedisStore) GetStore

func (r *RedisStore) GetStore() sessions.Store

type Ret

type Ret struct {
	Code    int `json:"code"`
	Data    any `json:"data,omitempty"`
	Message any `json:"message,omitempty"`
}

func ErrorRet

func ErrorRet(code int, message any) *Ret

func SuccessRet

func SuccessRet(data any) *Ret

type Router

type Router interface {
	Init(gin.IRouter)
}

type StoreOption

type StoreOption interface {
	GetStore() sessions.Store
}

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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