Documentation ¶
Index ¶
- func DefaultRedisClient() (client *redis.Client, err error)
- func GinResJSON(c *gin.Context, bts []byte)
- func IPFreqLimit1(client *redis.Client, dur time.Duration, number int, ...) (limiter func(*gin.Context), err error)
- func IPFreqLimit2(client *redis.Client, dur time.Duration, number int, ...) (limiter func(*gin.Context), err error)
- func RedisCache(client *redis.Client, rk string, fn func() (interface{}, error), dk string, ...) (bts []byte, code int, err error)
- type API
- type CallRedis
- type Config
- type ReqT
- type Selector
- type TomlEnv
- func (te *TomlEnv) Get(key string) (string, bool)
- func (te *TomlEnv) GetB(key string) (value bool, ok bool)
- func (te *TomlEnv) GetF(key string) (value float64, ok bool)
- func (te *TomlEnv) GetI(key string) (value int64, ok bool)
- func (te *TomlEnv) GetS(key string) (value string, ok bool)
- func (te *TomlEnv) Set(key string, value interface{}) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultRedisClient ¶
func GinResJSON ¶
func IPFreqLimit1 ¶
func IPFreqLimit1(client *redis.Client, dur time.Duration, number int, param func(*gin.Context) string) ( limiter func(*gin.Context), err error)
IPFreqLimit1 generate ip access frequence limiter middleware with redis set, internal error with redis will response 500 to client, overrun limit will response 429
@Parameter client redis client to user, can't be nil @Parameter dur record and count ip access in duration, must greater or equal time.Second @Parameter number maxmium access number, must greater than 0 @Parameter param function to generate identifier string as suffix @return limiter gin middleware @return err erorr of failed to create middleware
func IPFreqLimit2 ¶
func IPFreqLimit2(client *redis.Client, dur time.Duration, number int, param func(*gin.Context) string) ( limiter func(*gin.Context), err error)
IPFreqLimit2 generate ip access frequence limiter middleware with redis hset, internal error with redis will response 500 to client, overrun limit will response 429
@Parameter client redis client to user, can't be nil @Parameter dur record and count ip access in duration, must greater or equal time.Second @Parameter number maxmium access number, must greater than 0 @Parameter param function to generate identifier string as suffix @Return limiter gin middleware @Return err erorr of failed to create middleware
Types ¶
type API ¶
func (*API) Preprocess ¶
type CallRedis ¶
type CallRedis struct {
// contains filtered or unexported fields
}
func NewCallRedis ¶
func (*CallRedis) ResetExpire ¶
type Config ¶
type Config struct { Name string `json:"name"` S map[string]string `json:"s"` I map[string]int64 `json:"i"` F map[string]float64 `json:"f"` B map[string]bool `json:"b"` T map[string]time.Time `json:"t"` D map[string]dur `json:"d"` SX map[string][]string `json:"sx"` IX map[string][]int64 `json:"ix"` FX map[string][]float64 `json:"fx"` BX map[string][]bool `json:"bx"` TX map[string][]time.Time `json:"tx"` DX map[string][]dur `json:"dx"` }
type ReqT ¶
type Selector ¶
type Selector struct { Name string `json:"name"` JStr string `json:"jstr"` Exp string `json:"exp"` Type string `json:"type"` // xpath, css, templ Num int `json:"num"` // default is 1 Required bool `json:"required"` AsHTML bool `json:"as_html"` Templ *template.Template `json:"-"` }
func SelectorsFromToml ¶
Click to show internal directories.
Click to hide internal directories.