Documentation ¶
Index ¶
- Variables
- func AppName(name string) utils.OptionFunc[useOption]
- func CName(name string) utils.OptionFunc[clientOption]
- 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 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 New(opts ...utils.OptionExtender) *resty.Client
- func NewRequest(ctx context.Context, opts ...utils.OptionExtender) *resty.Request
- func Param(param map[string]any) utils.OptionFunc[errOption]
- func ParseFromBody() utils.OptionFunc[routerOption]
- func ParseFromQuery() utils.OptionFunc[routerOption]
- func RetryCondition(fn resty.RetryConditionFunc) utils.OptionFunc[clientOption]
- func RetryHook(fn resty.OnRetryFunc) utils.OptionFunc[clientOption]
- func RspError(c *gin.Context, data any, page, count int, msg string, err error, ...)
- func RspSuccess(c *gin.Context, data any, page, count int, msg string, ...)
- func StaticFileZeroCopy(filename string) func(c *gin.Context)
- type Conf
- type Embed
- type Errcode
- type IRouter
- type OutputConf
- type Response
Constants ¶
This section is empty.
Variables ¶
View Source
var (
Client *resty.Client
)
View Source
var (
I18n i18n.Localizable[Errcode]
)
Functions ¶
func AppName ¶
func AppName(name string) utils.OptionFunc[useOption]
func CName ¶
func CName(name string) utils.OptionFunc[clientOption]
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 New ¶
func New(opts ...utils.OptionExtender) *resty.Client
func NewRequest ¶
func NewRequest(ctx context.Context, opts ...utils.OptionExtender) *resty.Request
func ParseFromBody ¶
func ParseFromBody() utils.OptionFunc[routerOption]
func ParseFromQuery ¶
func ParseFromQuery() utils.OptionFunc[routerOption]
func RetryCondition ¶
func RetryCondition(fn resty.RetryConditionFunc) utils.OptionFunc[clientOption]
func RetryHook ¶
func RetryHook(fn resty.OnRetryFunc) utils.OptionFunc[clientOption]
func RspSuccess ¶ added in v1.1.12
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"` ErrorCode int `yaml:"error_code" json:"error_code" toml:"error_code" default:"-1"` 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"` EnableLogger bool `yaml:"enable_logger" json:"enable_logger" toml:"enable_logger"` LogInstance string `yaml:"log_instance" json:"log_instance" toml:"log_instance" default:"default"` Logger string `yaml:"logger" json:"logger" toml:"logger" default:"github.com/wfusion/gofusion/log/customlogger.httpLogger"` Asynq []asynqConf `yaml:"asynq" json:"asynq" toml:"asynq"` Clients map[string]*clientConf `yaml:"clients" json:"clients" toml:"clients"` Metrics metricsConf `yaml:"metrics" json:"metrics" toml:"metrics"` }
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() Running() <-chan struct{} Closing() <-chan struct{} // contains filtered or unexported methods }
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.