Documentation ¶
Index ¶
- Constants
- Variables
- func AddPProfHandler(router *gin.Engine)
- func AddWhiteList(url string)
- func AllocsHandler() gin.HandlerFunc
- func Bind(c *gin.Context, obj interface{}) bool
- func Bind2(c *gin.Context, obj interface{}) (bool, string)
- func BlockHandler() gin.HandlerFunc
- func CheckAuth() gin.HandlerFunc
- func CmdlineHandler() gin.HandlerFunc
- func Cors() gin.HandlerFunc
- func DoHttpRequest(method string, reqUrl string, headers map[string]string, body io.Reader) (int, []byte, error)
- func DoHttpRequestWithBody(method string, reqUrl string, headers map[string]string, reqBody interface{}) (int, []byte, error)
- func FormatReqUrl(reqUrl string, reqForm map[string]string) string
- func GenAuth(c *gin.Context, userId int64) error
- func GinLogger(threshold time.Duration) gin.HandlerFunc
- func GoroutineHandler() gin.HandlerFunc
- func HeapHandler() gin.HandlerFunc
- func HttpFormRequest(method, addr string, urlParams url.Values, headers map[string]string) ([]byte, int, error)
- func HttpForward(w http.ResponseWriter, r *http.Request, forwardUrl string) error
- func HttpPostJson(addr string, urlParams url.Values, headers map[string]string, body interface{}) ([]byte, int, error)
- func IndexHandler() gin.HandlerFunc
- func InitGinAuth(key string) error
- func LoadCfgFromFile(filename string, config *Configure) error
- func MutexHandler() gin.HandlerFunc
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(origData []byte) []byte
- func ProfileHandler() gin.HandlerFunc
- func SendFailResponse(c *gin.Context, errCode int, errDesc string)
- func SendSuccResponse(c *gin.Context, resp interface{})
- func SendSuccSimpleResponse(c *gin.Context, content string)
- func ShowAllRawBody(c *gin.Context)
- func SymbolHandler() gin.HandlerFunc
- func ThreadCreateHandler() gin.HandlerFunc
- func TimeCounter() func()
- func TraceHandler() gin.HandlerFunc
- func WrapGroup(router *gin.RouterGroup)
- type AesCbcPKCS7
- type Configure
- type Empty
- type FailResponse
- type LogConfig
- type MysqlConfig
- type OssConfig
- type RedisConfig
- type ResponseBase
- type Set
- type SimpleResponse
- type UserAgent
Constants ¶
const ( StdDateFormat = "2006-01-02" StdTimeFormat = "15:04:05" StdDateTimeFormat = "2006-01-02 15:04:05" StdTimeWithMsec = "15:04:05.999999999" StdDateTimeWithMsec = "2006-01-02 15:04:05.999999999" StdTimeWithMsecAndTimeZone = "15:04:05.999999999Z07:00" StdDateTimeWithMsecAndTimeZone = "2006-01-02 15:04:05.999999999Z07:00" )
Variables ¶
var AddPProfHandlerWrapper = AddPProfHandler
AddPProfHandlerWrapper make sure we are backward compatible
Functions ¶
func AddPProfHandler ¶
AddPProfHandler adds several routes from package `net/http/pprof` to *gin.Engine object
func AddWhiteList ¶
func AddWhiteList(url string)
func AllocsHandler ¶
func AllocsHandler() gin.HandlerFunc
AllocsHandler will pass the call from /debug/pprof/allocs to pprof
func BlockHandler ¶
func BlockHandler() gin.HandlerFunc
BlockHandler will pass the call from /debug/pprof/block to pprof
func CheckAuth ¶
func CheckAuth() gin.HandlerFunc
func CmdlineHandler ¶
func CmdlineHandler() gin.HandlerFunc
CmdlineHandler will pass the call from /debug/pprof/cmdline to pprof
func Cors ¶
func Cors() gin.HandlerFunc
func DoHttpRequest ¶
func DoHttpRequest(method string, reqUrl string, headers map[string]string, body io.Reader) (int, []byte, error)
method POST GET headers Ext Header
func DoHttpRequestWithBody ¶
func FormatReqUrl ¶
有reqform时,可能需要设置header:request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
func GoroutineHandler ¶
func GoroutineHandler() gin.HandlerFunc
GoroutineHandler will pass the call from /debug/pprof/goroutine to pprof
func HeapHandler ¶
func HeapHandler() gin.HandlerFunc
HeapHandler will pass the call from /debug/pprof/heap to pprof
func HttpFormRequest ¶
func HttpForward ¶
func HttpPostJson ¶
func IndexHandler ¶
func IndexHandler() gin.HandlerFunc
IndexHandler will pass the call from /debug/pprof to pprof
func InitGinAuth ¶
func LoadCfgFromFile ¶
example: LoadCfgFromFile("./config.json", cfg)
func MutexHandler ¶
func MutexHandler() gin.HandlerFunc
MutexHandler will pass the call from /debug/pprof/mutex to pprof
func PKCS7Padding ¶
func PKCS7UnPadding ¶
func ProfileHandler ¶
func ProfileHandler() gin.HandlerFunc
ProfileHandler will pass the call from /debug/pprof/profile to pprof
func SendSuccResponse ¶
func SendSuccSimpleResponse ¶
func ShowAllRawBody ¶
func SymbolHandler ¶
func SymbolHandler() gin.HandlerFunc
SymbolHandler will pass the call from /debug/pprof/symbol to pprof
func ThreadCreateHandler ¶
func ThreadCreateHandler() gin.HandlerFunc
ThreadCreateHandler will pass the call from /debug/pprof/threadcreate to pprof
func TraceHandler ¶
func TraceHandler() gin.HandlerFunc
TraceHandler will pass the call from /debug/pprof/trace to pprof
func WrapGroup ¶
func WrapGroup(router *gin.RouterGroup)
WrapGroup adds several routes from package `net/http/pprof` to *gin.RouterGroup object
Types ¶
type AesCbcPKCS7 ¶
var AuthAes *AesCbcPKCS7
func NewAesCbcPKCS7 ¶
func NewAesCbcPKCS7(key string) *AesCbcPKCS7
func (*AesCbcPKCS7) AesCBCDecrypt ¶
func (obj *AesCbcPKCS7) AesCBCDecrypt(encryptData []byte) ([]byte, error)
func (*AesCbcPKCS7) AesCBCEncrypt ¶
func (obj *AesCbcPKCS7) AesCBCEncrypt(rawData []byte) ([]byte, error)
type Configure ¶
type Configure struct { Listen string LogSetting LogConfig //推荐 MysqlSetting map[string]MysqlConfig RedisSetting map[string]RedisConfig OssSetting map[string]OssConfig External map[string]string ExternalInt64 map[string]int64 GormDebug bool //sql 输出开关 Environment string //环境变量区分, ONLINE/TEST }
var Config *Configure
type FailResponse ¶
type FailResponse struct { // 错误码。0为正常返回,其它为异常,异常时ErrDesc为异常描述。 固定的异常描述请存储于err_code_def.go文件中 ErrCode int `json:"err_code"` // 错误信息。可展示在页面上 ErrDesc string `json:"err_desc"` // 用于定位某次调用的ID,客户端应该在错误时显示(ErrCode:TraceId) TraceId string `json:"trace_id"` }
swagger:model
type MysqlConfig ¶
type RedisConfig ¶
type ResponseBase ¶
type ResponseBase struct { // 错误码。这里的值为0,主要是为了返回体中有ErrCode字段 ErrCode int `json:"err_code"` }
swagger:model
type SimpleResponse ¶
type SimpleResponse struct { // 错误码。这里的值为0,主要是为了返回体中有ErrCode字段 ErrCode int `json:"err_code"` // 返回的内容 Content string `json:"content"` }
swagger:model