Documentation
¶
Index ¶
- Constants
- Variables
- func UseHttpProxy(contextKey string) echo.MiddlewareFunc
- type HttpPeer
- type HttpProxy
- type HttpProxyOption
- type HttpProxyOptioner
- func (o HttpProxyOptioner) WithAddr(direct, redirect string) HttpProxyOption
- func (o HttpProxyOptioner) WithKey(contextKey string) HttpProxyOption
- func (o HttpProxyOptioner) WithLogger(logger echo.Logger) HttpProxyOption
- func (o HttpProxyOptioner) WithScheme(scheme string) HttpProxyOption
- func (o HttpProxyOptioner) WithTls(enable bool) HttpProxyOption
- type ParamSet
- type Proxy
Constants ¶
View Source
const ( UserAgent = "go-puzzle/1.0" ParamHeader = "header" ParamBody = "body" ParamPath = "path" ParamQuery = "query" HeaderCookie = "Cookie" HeaderContentType = "Content-Type" HeaderUserAgent = "User-Agent" HeaderAuthorization = "Authorization" HeaderXForwardFor = "X-Forward-For" HeaderXRequestId = "X-Request-ID" BodyJson = "application/json" )
View Source
const ( DefaultDerect = "127.0.0.1:80" DefaultTimeout = 10 * time.Second DefaultMaxIdleConn = 100 DefaultMaxConnPerHost = 20 DefaultMaxIdleConnPerHost = 10 DefaultMaxResHeaderSize = 1 << 20 SchemeHttp = "http://" SchemeHttps = "https://" )
Variables ¶
View Source
var ( ErrInvalidPattern = errors.New("invalid uri pattern") ErrUnmatchPath = errors.New("no match path param") ErrProxyReq = errors.New("empty proxy request") ErrMissingQuery = errors.New("missing query param") ErrEmptyResponse = errors.New("parse empty response") ErrContextKey = errors.New("unmatched http proxy context key") )
Functions ¶
func UseHttpProxy ¶
func UseHttpProxy(contextKey string) echo.MiddlewareFunc
Types ¶
type HttpPeer ¶
type HttpProxy ¶
type HttpProxy interface {
Proxy
ContextKey() string
GenRequest(c echo.Context, peer HttpPeer) error
SetupProxy(c echo.Context)
GoProxy() error
GetParamSet() ParamSet
GetRequest() *http.Request
GetResponse() *http.Response
OriginBody() ([]byte, error)
Bind(s interface{}) error
Transparent(c echo.Context, peer HttpPeer) ([]byte, error)
TransparentWithJson(c echo.Context, peer HttpPeer, s interface{}) error
}
func NewHttpProxy ¶
func NewHttpProxy(opts ...HttpProxyOption) HttpProxy
type HttpProxyOption ¶
type HttpProxyOption func(p *httpProxy)
type HttpProxyOptioner ¶
type HttpProxyOptioner struct{}
func (HttpProxyOptioner) WithAddr ¶
func (o HttpProxyOptioner) WithAddr(direct, redirect string) HttpProxyOption
func (HttpProxyOptioner) WithKey ¶
func (o HttpProxyOptioner) WithKey(contextKey string) HttpProxyOption
func (HttpProxyOptioner) WithLogger ¶
func (o HttpProxyOptioner) WithLogger(logger echo.Logger) HttpProxyOption
func (HttpProxyOptioner) WithScheme ¶
func (o HttpProxyOptioner) WithScheme(scheme string) HttpProxyOption
func (HttpProxyOptioner) WithTls ¶
func (o HttpProxyOptioner) WithTls(enable bool) HttpProxyOption
Click to show internal directories.
Click to hide internal directories.