ginx

package
v0.0.0-...-62a34bc Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RES_CODE_OK = iota
	RES_CODE_GENERAL_ERROR
	RES_CODE_INVALID_REQ
	RES_CODE_NOT_FOUND
	RES_CODE_ALREADY_EXIST
	RES_CODE_NOT_AUTHED
	RES_CODE_NOT_ALLOWED
)

Variables

This section is empty.

Functions

func AddRoutes

func AddRoutes(group *gin.RouterGroup, path, pluralPath string, controller any)

func InitConf

func InitConf(path string, conf any) error

func MetaRouteRegister

func MetaRouteRegister(r *gin.Engine, strs ...string)

func MetaRouteRegisterAll

func MetaRouteRegisterAll(r *gin.Engine)

func NewGormMysql

func NewGormMysql(conf *GormMysqlConf) (*gorm.DB, error)

func NewLogger

func NewLogger(writer io.Writer, logPath string, logLevel int) (*logger.Logger, error)

func NewRedis

func NewRedis(conf *RedisConf) *redis.Client

Types

type G

type G struct {
	*gin.Context
}

func (*G) ParsePathId

func (g *G) ParsePathId(key string) (uint, error)

func (*G) ParseQueryDate

func (g *G) ParseQueryDate(key string) *time.Time

func (*G) ParseQueryId

func (g *G) ParseQueryId(key string) uint

func (*G) ParseQueryIdList

func (g *G) ParseQueryIdList(key string) []uint

func (*G) ParseQueryPageArgs

func (g *G) ParseQueryPageArgs(maxSize uint64) (limit, offset uint)

func (*G) RenderData

func (g *G) RenderData(data any)

func (*G) RenderDataOrError

func (g *G) RenderDataOrError(data any, err error)

func (*G) RenderError

func (g *G) RenderError(err error)

func (*G) RenderMessage

func (g *G) RenderMessage(code int, message string)

type GormMysqlConf

type GormMysqlConf struct {
	Dsn     string
	Mysql   *mysql.Config
	Gorm    *gorm.Config
	MaxIdle int
	MaxOpen int
}

type ICreateController

type ICreateController interface {
	Create(*G)
}

type IDeleteController

type IDeleteController interface {
	Delete(*G)
}

type IGetController

type IGetController interface {
	Get(*G)
}

type IListController

type IListController interface {
	List(*G)
}

type IUpdateController

type IUpdateController interface {
	Update(*G)
}

type RedisConf

type RedisConf struct {
	Red *RedisInstConf
	Db  int
}

type RedisInstConf

type RedisInstConf struct {
	Addr           string
	Password       string
	DialTimeoutMs  int64 `yaml:"dial_timeout_ms"`
	ReadTimeoutMs  int64 `yaml:"read_timeout_ms"`
	WriteTimeoutMs int64 `yaml:"write_timeout_ms"`
}

type Resp

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

type RespError

type RespError struct {
	Status  int
	Code    int
	Message string
}

func (*RespError) Error

func (e *RespError) Error() string

Jump to

Keyboard shortcuts

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