requests

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Direct = direct{}

Direct is a direct proxy: one that makes network connections directly.

View Source
var HttpsDialer = httpsDialer{}

HTTPSDialer is a https proxy: one that makes network connections on tls.

View Source
var TlsConfig = &tls.Config{}

Functions

func ExistsUrl

func ExistsUrl(remoteURL string) bool

func FilterIPs

func FilterIPs(cidrs []string, h http.Handler) http.Handler

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 FromEnvironment() proxy.Dialer

func FromHTTPProxy

func FromHTTPProxy(proxyURI string) (proxy.Dialer, error)

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 FromURL

func FromURL(u *url.URL, forward proxy.Dialer) (proxy.Dialer, error)

func Get

func Get(ctx context.Context, url string) *http.Request

func InjectHTTPClientMonitor

func InjectHTTPClientMonitor()

func JSON

func JSON(w http.ResponseWriter, code int, v interface{}) error

func Post

func Post(posturl string, req interface{}, headers ...url.Values) (resp *http.Response, err error)

func PostStruct

func PostStruct(posturl string, req interface{}, response interface{}, headers ...url.Values) (err error)

func ReadBytes

func ReadBytes(resp *http.Response, err error) ([]byte, error)

func ReadJson

func ReadJson(resp *http.Response, err error, i interface{}) error

func WrapHTTPServerMonitor

func WrapHTTPServerMonitor(handler http.Handler) http.Handler

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL