Documentation ¶
Index ¶
- Constants
- func APILog(lgg *zap.Logger, name string, skip int) gin.HandlerFunc
- func BasicAuth(username, password string, handle func(*gin.Context, string)) gin.HandlerFunc
- func BasicBcrypt(username, password string, handle func(*gin.Context, ...string)) gin.HandlerFunc
- func CacheControl(seconds int) gin.HandlerFunc
- func Cors(origin string) gin.HandlerFunc
- func Get[T any](ctx *gin.Context, key string) (item T, err error)
- func GetDate(ctx *gin.Context) (*time.Time, error)
- func Healthz(ctx *gin.Context)
- func IndexStaticFiles(router *gin.RouterGroup, d string) (err error)
- func ServeStaticDir(httpDir, local string, listDir bool) func(*gin.RouterGroup)
- func ServeStaticFile(bts []byte, name string) gin.HandlerFunc
- func SetData(ctx *gin.Context, kvs map[string]any)
- func SetError(ctx *gin.Context, err any)
- func SetIdentity(ctx *gin.Context, kvs map[string]string)
- func SetRequestId(ctx *gin.Context, requestId string)
- func WsUpgrade(ctx *gin.Context)
- type HttpConfig
Constants ¶
View Source
const ( GIN_RequestId = "GIN_RequestId" GIN_Error = "GIN_Error" GIN_Identity = "GIN_Identity" // string GIN_Data = "GIN_Data" // map[string]any )
Variables ¶
This section is empty.
Functions ¶
func BasicBcrypt ¶
handle key: no_token, invalid_token, incorrect_token, User:XXXX
func CacheControl ¶
func CacheControl(seconds int) gin.HandlerFunc
func Cors ¶
func Cors(origin string) gin.HandlerFunc
func IndexStaticFiles ¶
func IndexStaticFiles(router *gin.RouterGroup, d string) (err error)
func ServeStaticDir ¶
func ServeStaticDir(httpDir, local string, listDir bool) func(*gin.RouterGroup)
func ServeStaticFile ¶
func ServeStaticFile(bts []byte, name string) gin.HandlerFunc
name: filename, e.g. favicon.ico ct: Content-Type, e.g. image/x-icon
func SetRequestId ¶
Types ¶
type HttpConfig ¶
type HttpConfig struct { Path string `mapstructure:"path"` Cors string `mapstructure:"cors"` Tls bool `mapstructure:"tls"` Cert string `mapstructure:"cert"` Key string `mapstructure:"key"` }
func (*HttpConfig) FromFile ¶
func (self *HttpConfig) FromFile(fp string) (err error)
func (*HttpConfig) SetEngine ¶
func (self *HttpConfig) SetEngine(engine *gin.Engine)
Click to show internal directories.
Click to hide internal directories.