Documentation ¶
Index ¶
- Variables
- func ExistsUrl(remoteURL string) bool
- func FilterIPs(cidrs []string, h http.Handler) http.Handler
- func FromEnvironment() proxy.Dialer
- func FromHTTPProxy(proxyURI string) (proxy.Dialer, error)
- func FromURL(u *url.URL, forward proxy.Dialer) (proxy.Dialer, error)
- func Get(ctx context.Context, url string) *http.Request
- func InjectHTTPClientMonitor()
- func JSON(w http.ResponseWriter, code int, v interface{}) error
- func Post(posturl string, req interface{}, headers ...url.Values) (resp *http.Response, err error)
- func PostStruct(posturl string, req interface{}, response interface{}, headers ...url.Values) (err error)
- func ReadBytes(resp *http.Response, err error) ([]byte, error)
- func ReadJson(resp *http.Response, err error, i interface{}) error
- func WrapHTTPServerMonitor(handler http.Handler) http.Handler
- type FuzzyPathStore
- type HTTPResponseInterceptor
Constants ¶
This section is empty.
Variables ¶
var Direct = direct{}
Direct is a direct proxy: one that makes network connections directly.
var HttpsDialer = httpsDialer{}
HTTPSDialer is a https proxy: one that makes network connections on tls.
var TlsConfig = &tls.Config{}
Functions ¶
func FilterIPs ¶
FilterIPs is a middleware to filter requests by IP. cidrs is a list of CIDR strings. For example, "23.102.140.112/28" openai or "127.0.0.1/32" for local test.
func FromEnvironment ¶
func FromHTTPProxy ¶
FromHTTPProxy returns HTTP tunnel dialer proxying tcp connection. Copy from https://gist.github.com/jim3ma/3750675f141669ac4702bc9deaf31c6b Usage: dialer, err := DialWithHTTPProxy("http://your http proxy:3128") lg.PanicError(err) conn, err := httpDialer.Dial("tcp", "google.com:80") lg.PanicError(err) fmt.Printf("Create http tunnel OK: %+v\n", conn)
func InjectHTTPClientMonitor ¶
func InjectHTTPClientMonitor()
func PostStruct ¶
Types ¶
type FuzzyPathStore ¶
type FuzzyPathStore struct {
// contains filtered or unexported fields
}
func NewFuzzyPathStore ¶
func NewFuzzyPathStore() *FuzzyPathStore
func (*FuzzyPathStore) CleanPath ¶
func (fps *FuzzyPathStore) CleanPath(path string) string
type HTTPResponseInterceptor ¶
type HTTPResponseInterceptor struct { http.ResponseWriter StatusCode int }
func NewHTTPResponseInterceptor ¶
func NewHTTPResponseInterceptor(w http.ResponseWriter) *HTTPResponseInterceptor
NewHTTPResponseInterceptor create new httpInterceptor
func (*HTTPResponseInterceptor) Hijack ¶
func (i *HTTPResponseInterceptor) Hijack() (net.Conn, *bufio.ReadWriter, error)
Implemented Hijack interface to be compatible with websocket. https://pkg.go.dev/net/http#Hijacker
func (*HTTPResponseInterceptor) WriteHeader ¶
func (i *HTTPResponseInterceptor) WriteHeader(code int)
WriteHeader override response WriteHeader