Documentation ¶
Index ¶
- Variables
- func AppName(name string) utils.OptionFunc[useOption]
- func Construct(ctx context.Context, conf Conf, opts ...utils.OptionExtender) func()
- func ContentZeroCopy(fn getContentFn, opts ...utils.OptionExtender) func(c *gin.Context)
- func Err(c *gin.Context, code Errcode, opts ...utils.OptionExtender) error
- func ErrCtx(ctx context.Context, code Errcode, opts ...utils.OptionExtender) error
- func Error[T constraint.Integer](c *gin.Context, appName string, code T, data any, page, count int, msg string)
- func HandleAfter(aftersHandlers ...routerHandler) utils.OptionFunc[routerOption]
- func HandleBefore(beforeHandlers ...routerHandler) utils.OptionFunc[routerOption]
- func Langs(c *gin.Context) utils.OptionFunc[errOption]
- func Localizable(opts ...utils.OptionExtender) i18n.Localizable[Errcode]
- func Msg(msg string) utils.OptionFunc[errOption]
- func Param(param map[string]any) utils.OptionFunc[errOption]
- func ParseFromBody() utils.OptionFunc[routerOption]
- func ParseFromQuery() utils.OptionFunc[routerOption]
- func StaticFileZeroCopy(filename string) func(c *gin.Context)
- func Success(c *gin.Context, appName string, data any, page, count int, msg string)
- type Conf
- type Embed
- type Errcode
- type IRouter
- type OutputConf
- type Response
Constants ¶
This section is empty.
Variables ¶
View Source
var (
I18n i18n.Localizable[Errcode]
)
Functions ¶
func AppName ¶
func AppName(name string) utils.OptionFunc[useOption]
func Construct ¶
func Construct(ctx context.Context, conf Conf, opts ...utils.OptionExtender) func()
func ContentZeroCopy ¶
func ContentZeroCopy(fn getContentFn, opts ...utils.OptionExtender) func(c *gin.Context)
ContentZeroCopy zero copy gin handler wrapper for seeker
func HandleAfter ¶
func HandleAfter(aftersHandlers ...routerHandler) utils.OptionFunc[routerOption]
func HandleBefore ¶
func HandleBefore(beforeHandlers ...routerHandler) utils.OptionFunc[routerOption]
func Localizable ¶
func Localizable(opts ...utils.OptionExtender) i18n.Localizable[Errcode]
func Msg ¶
func Msg(msg string) utils.OptionFunc[errOption]
func ParseFromBody ¶
func ParseFromBody() utils.OptionFunc[routerOption]
func ParseFromQuery ¶
func ParseFromQuery() utils.OptionFunc[routerOption]
func StaticFileZeroCopy ¶
StaticFileZeroCopy zero copy gin handler wrapper for static file
Types ¶
type Conf ¶
type Conf struct { Port int `yaml:"port" json:"port" toml:"port" default:"80"` TLS bool `yaml:"tls" json:"tls" toml:"tls" default:"false"` Cert string `yaml:"cert" json:"cert" toml:"cert"` Key string `yaml:"key" json:"key" toml:"key"` NextProtos []string `yaml:"next_protos" json:"next_protos" toml:"next_protos" default:"[http/1.1]"` // h2, http/1.1 is ok SuccessCode int `yaml:"success_code" json:"success_code" toml:"success_code"` Pprof bool `yaml:"pprof" json:"pprof" toml:"pprof"` XSSWhiteURLList []string `yaml:"xss_white_url_list" json:"xss_white_url_list" toml:"xss_white_url_list" default:"[]"` ColorfulConsole bool `yaml:"colorful_console" json:"colorful_console" toml:"colorful_console" default:"false"` ReadTimeout string `yaml:"read_timeout" json:"read_timeout" toml:"read_timeout" default:"10s"` WriteTimeout string `yaml:"write_timeout" json:"write_timeout" toml:"write_timeout" default:"10s"` Asynq []*asynqConf `yaml:"asynq" json:"asynq" toml:"asynq"` LogInstance string `yaml:"log_instance" json:"log_instance" toml:"log_instance" default:"default"` }
Conf http configure nolint: revive // struct field annotation issue
type IRouter ¶
type IRouter interface { Use(middlewares ...gin.HandlerFunc) IRouter Handle(uri string, fn routerHandler, opts ...utils.OptionExtender) IRouter Any(uri string, fn routerHandler, opts ...utils.OptionExtender) IRouter GET(uri string, fn routerHandler, opts ...utils.OptionExtender) IRouter POST(uri string, fn routerHandler, opts ...utils.OptionExtender) IRouter DELETE(uri string, fn routerHandler, opts ...utils.OptionExtender) IRouter PATCH(uri string, fn routerHandler, opts ...utils.OptionExtender) IRouter PUT(uri string, fn routerHandler, opts ...utils.OptionExtender) IRouter OPTIONS(uri string, fn routerHandler, opts ...utils.OptionExtender) IRouter HEAD(uri string, fn routerHandler, opts ...utils.OptionExtender) IRouter Group(relativePath string, handlers ...gin.HandlerFunc) IRouter StaticFile(string, string) IRouter StaticFileFS(string, string, http.FileSystem) IRouter Static(string, string) IRouter StaticFS(string, http.FileSystem) IRouter ServeHTTP(http.ResponseWriter, *http.Request) Config() OutputConf ListenAndServe() error Start() }
var (
Router IRouter
)
func Use ¶
func Use(opts ...utils.OptionExtender) IRouter
type OutputConf ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.