Documentation
¶
Index ¶
- Constants
- func CheckSign(sign, appid, path, ts string) (ok bool)
- func ClientIP(r *http.Request, rHeader http.Header) string
- func File(c *gin.Context, filePath, fileName string)
- func GinProxy[Rsp any](c *gin.Context, method, host, uri string) (rspParam Rsp, err error)
- func GinPureProxy(c *gin.Context, method, host, uri string)
- func JSON(c *gin.Context, data any, err error)
- func ReadRequestBody(req *http.Request) (bs []byte, err error)
- func Redirect(c *gin.Context, location string)
- func VerifySign(c *gin.Context)
- type AccessConfig
- type CommonRsp
- type Config
- type GinEngine
- func (g *GinEngine) AccessLog(ac *AccessConfig) gin.HandlerFunc
- func (g *GinEngine) AddExitHook(hooks ...HookFunc) *GinEngine
- func (g *GinEngine) AddShutdownHook(hooks ...HookFunc) *GinEngine
- func (g *GinEngine) CORS() gin.HandlerFunc
- func (g *GinEngine) Close()
- func (g *GinEngine) Logger(ignoreRelease bool) gin.HandlerFunc
- func (g *GinEngine) Recovery() gin.HandlerFunc
- func (g *GinEngine) Start()
- type HookFunc
- type HttpRsp
- type OutputType
- type Pager
- type RecoverInfo
Constants ¶
View Source
const ( TypeOctetStream = "application/octet-stream" TypeForm = "application/x-www-form-urlencoded" TypeJson = "application/json" TypeXml = "application/xml" TypeJpg = "image/jpeg" TypePng = "image/png" )
Variables ¶
This section is empty.
Functions ¶
func GinPureProxy ¶ added in v1.0.25
GinPureProxy gin request proxy
Types ¶
type AccessConfig ¶ added in v1.0.26
type AccessConfig struct {
AppName string `json:"app_name" yaml:"app_name" toml:"app_name"` // app name,记录日志标识
OutputType OutputType `json:"output_type" yaml:"output_type" toml:"output_type"` // 日志输出类型:stdout、file、sls
FilePath string `json:"file_path" yaml:"file_path" toml:"file_path"` // 日志输出文件路径(输出类型为file时有效)
SlsAccessKey string `json:"sls_access_key" yaml:"sls_access_key" toml:"sls_access_key"` // 日志输出到阿里云SLS时的access_key
SlsSecretKey string `json:"sls_secret_key" yaml:"sls_secret_key" toml:"sls_secret_key"` // 日志输出到阿里云SLS时的secret_key
SlsEndpoint string `json:"sls_endpoint" yaml:"sls_endpoint" toml:"sls_endpoint"` // 日志输出到阿里云SLS时的endpoint
SlsProject string `json:"sls_project" yaml:"sls_project" toml:"sls_project"` // 日志输出到阿里云SLS时的project
SlsLogStore string `json:"sls_log_store" yaml:"sls_log_store" toml:"sls_log_store"` // 日志输出到阿里云SLS时的log_store
}
type Config ¶
type Config struct {
Addr string `json:"addr" yaml:"addr" toml:"addr"` // addr, default :2233
ReadTimeout xtime.Duration `json:"read_timeout" yaml:"read_timeout" toml:"read_timeout"` // read_timeout, default 60s
WriteTimeout xtime.Duration `json:"write_timeout" yaml:"write_timeout" toml:"write_timeout"` // write_timeout, default 60s
Debug bool `json:"debug" yaml:"debug" toml:"debug"` // is show log
Limiter *limit.Config `json:"limiter" yaml:"limiter" toml:"limiter"` // interface limit
Trace *trace.Config `json:"trace" yaml:"trace" toml:"trace"` // jaeger trace config
}
type GinEngine ¶
type GinEngine struct {
Gin *gin.Engine
Tracer *trace.Tracer
IgnoreReleaseLog bool
// contains filtered or unexported fields
}
func (*GinEngine) AccessLog ¶ added in v1.0.26
func (g *GinEngine) AccessLog(ac *AccessConfig) gin.HandlerFunc
AccessLog middleware for request and response body
func (*GinEngine) AddExitHook ¶ added in v1.0.29
添加 GinServer 进程退出时钩子函数
func (*GinEngine) AddShutdownHook ¶ added in v1.0.30
添加 GinServer 服务关闭时的钩子函数
func (*GinEngine) Logger ¶ added in v1.0.20
func (g *GinEngine) Logger(ignoreRelease bool) gin.HandlerFunc
Logger
func (*GinEngine) Recovery ¶
func (g *GinEngine) Recovery() gin.HandlerFunc
Recovery gin middleware recovery
type OutputType ¶ added in v1.0.26
type OutputType string
const ( OutputStdout OutputType = "stdout" OutputSLS OutputType = "sls" OutputFile OutputType = "file" )
Click to show internal directories.
Click to hide internal directories.