Documentation ¶
Index ¶
- Constants
- Variables
- func AuthHandler(handler xoidc.OidcAuthFuncHandler) gin.HandlerFunc
- func BaseHandler(handler ...HandlerFunc) gin.HandlerFunc
- func Bind(c *gin.Context, out interface{}) error
- func BindJSON(c *gin.Context, out interface{}) error
- func CopyBody(c *gin.Context) (io.ReadCloser, error)
- func DoHandler(handler ...HandlerFunc) gin.HandlerFunc
- func EncodeHTTPHeader(data map[string][]string) string
- func GetALLParams(c *gin.Context) map[string]string
- func GetPar(c *gin.Context) map[string]string
- func GetQueryPar(c *gin.Context) map[string]string
- func GinContext(c *gin.Context) context.Context
- func GinInterceptorOpenTracing(tr opentracing.Tracer) gin.HandlerFunc
- func GinLog(c *gin.Context) *logrus.Entry
- func NewSingleHostReverseProxy(data *url.URL) *httputil.ReverseProxy
- func PostFormPar(c *gin.Context) map[string]string
- func ProxyURL(c *gin.Context, targeturl string, fn FilterHandler) bool
- func ProxyURLV2(c *gin.Context, targeturl string, fn FilterHandler) (string, bool)
- func ReadBody(c *gin.Context) []byte
- func ReadBodyv2(rc io.ReadCloser) (io.ReadCloser, string, error)
- func RealIP(ctx *gin.Context) string
- func RunEngine(sv ServerInfo, fn GinHandler) error
- func RunRouter(engine *gin.Engine, sv ServerInfo) (err error)
- func ShiftRequest(c *gin.Context, api string, sec int, retry int, header xtools.ES) (result string, err error)
- func ShiftSvcPath(c *gin.Context, svc string) (string, error)
- func TraceID(c *gin.Context) string
- type ContentType
- type FilterHandler
- type FilterOption
- type GinHandler
- type HandlerFunc
- type IRet
- type Ret
- type RetString
- type ServerInfo
Constants ¶
View Source
const ( //User-Agent USER_AGENT string = "xpkg/v2" )
Variables ¶
View Source
var DefaultTransport = &http.Transport{ DialContext: (&net.Dialer{ Timeout: 1 * time.Second, KeepAlive: 30 * time.Second, DualStack: true, }).DialContext, MaxIdleConns: 100, IdleConnTimeout: 90 * time.Second, ExpectContinueTimeout: 1 * time.Second, TLSHandshakeTimeout: 3 * time.Second, }
DefaultTransport http keepalive 30s var tp http.RoundTripper
View Source
var ProxyTransport = &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: -1, DualStack: true, }).DialContext, ForceAttemptHTTP2: true, DisableKeepAlives: true, MaxIdleConns: 1, IdleConnTimeout: 90 * time.Second, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second, }
var DefaultTransport = &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, DualStack: true, }).DialContext, ForceAttemptHTTP2: true, MaxIdleConns: 100, IdleConnTimeout: 90 * time.Second, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second, }
View Source
var (
SingleHostReverseProxy = map[string]*httputil.ReverseProxy{}
)
Functions ¶
func AuthHandler ¶
func AuthHandler(handler xoidc.OidcAuthFuncHandler) gin.HandlerFunc
func BaseHandler ¶
func BaseHandler(handler ...HandlerFunc) gin.HandlerFunc
func EncodeHTTPHeader ¶
func GinInterceptorOpenTracing ¶
func GinInterceptorOpenTracing(tr opentracing.Tracer) gin.HandlerFunc
func NewSingleHostReverseProxy ¶
func NewSingleHostReverseProxy(data *url.URL) *httputil.ReverseProxy
func PostFormPar ¶
func PostFormPar(c *gin.Context) map[string]string { 获取所有请求参数
func ProxyURLV2 ¶
func ReadBodyv2 ¶
func ReadBodyv2(rc io.ReadCloser) (io.ReadCloser, string, error)
func RunEngine ¶
func RunEngine(sv ServerInfo, fn GinHandler) error
func ShiftRequest ¶
Types ¶
type ContentType ¶
type ContentType string
const ( APPLICATION_JSON ContentType = "application/json" //text/html;text/plain; charset=utf-8 TEXT_HTML ContentType = "text/html" TEXT_PLAIN ContentType = "text/plain; charset=utf-8" //application/javascript APPLICATION_JAVASCRIPT ContentType = "application/javascript" //application/xml APPLICATION_XML ContentType = "application/xml" //application/x-www-form-urlencoded APPLICATION_URLENCODED ContentType = "application/x-www-form-urlencoded" )
type FilterHandler ¶
type FilterHandler func(ctx context.Context, opt FilterOption) bool
type FilterOption ¶
type FilterOption struct { Path string `json:"path"` Query map[string]string `json:"query"` Body []byte `json:"body"` }
func (*FilterOption) GetBodyJSON ¶
func (c *FilterOption) GetBodyJSON(out interface{}) error
type GinHandler ¶
type HandlerFunc ¶
type IRet ¶
type Ret ¶
type Ret struct { Ret codes.Code `json:"ret"` Msg string `json:"msg,omitempty"` Data interface{} `json:"data,omitempty"` Trace string `json:"trace,omitempty"` }
func (*Ret) GetRet ¶
func (c *Ret) GetRet() (string, ContentType)
type RetString ¶
type RetString struct {
// contains filtered or unexported fields
}
func NewRetString ¶
func NewRetStringv2 ¶
func NewRetStringv2(data string, ct ContentType) *RetString
func (*RetString) GetRet ¶
func (c *RetString) GetRet() (string, ContentType)
type ServerInfo ¶
Click to show internal directories.
Click to hide internal directories.