Documentation ¶
Index ¶
- Constants
- func DefaultClientOptions() []hzconfig.ClientOption
- func IsASCIIPrint(s string) bool
- func JoinURLPath(req *protocol.Request, target string) (path []byte)
- func New(opts Options, client *client.Client) (proxy.Proxy, error)
- func NewClient(opts ClientOptions) (*client.Client, error)
- type ClientOptions
- type HTTPProxy
- func (p *HTTPProxy) AddFailedCount(count uint) error
- func (p *HTTPProxy) Close() error
- func (p *HTTPProxy) ID() string
- func (p *HTTPProxy) IsAvailable() bool
- func (p *HTTPProxy) ServeHTTP(ctx context.Context, c *app.RequestContext)
- func (p *HTTPProxy) SetClient(client *client.Client)
- func (p *HTTPProxy) SetDirector(director func(req *protocol.Request))
- func (p *HTTPProxy) SetErrorHandler(eh func(c *app.RequestContext, err error))
- func (r *HTTPProxy) SetTransferTrailer(b bool)
- func (p *HTTPProxy) Target() string
- func (p *HTTPProxy) Weight() uint32
- type Options
Constants ¶
const TrailerPrefix = "Trailer:"
TrailerPrefix is a magic prefix for [ResponseWriter.Header] map keys that, if present, signals that the map entry is actually for the response trailers, and not the response headers. The prefix is stripped after the ServeHTTP call finishes and the values are sent in the trailers.
This mechanism is intended only for trailers that are not known prior to the headers being written. If the set of trailers is fixed or known before the header is written, the normal Go trailers mechanism is preferred:
https://pkg.go.dev/net/http#ResponseWriter https://pkg.go.dev/net/http#example-ResponseWriter-Trailers
Variables ¶
This section is empty.
Functions ¶
func DefaultClientOptions ¶
func DefaultClientOptions() []hzconfig.ClientOption
func IsASCIIPrint ¶
IsASCIIPrint returns whether s is ASCII and printable according to https://tools.ietf.org/html/rfc20#section-4.2.
func New ¶
New creates a new reverse proxy instance.
It takes a set of options and a client as parameters, and returns a new reverse proxy instance and an error. The options parameter specifies the target URL and other configuration options for the reverse proxy. The client parameter specifies the client to use for making requests to the target URL. The returned error is nil if the reverse proxy instance is created successfully, or an error if there is a problem.
Types ¶
type ClientOptions ¶
type ClientOptions struct { IsTracingEnabled bool IsHTTP2 bool HZOptions []hzconfig.ClientOption }
type HTTPProxy ¶
type HTTPProxy struct {
// contains filtered or unexported fields
}
func (*HTTPProxy) AddFailedCount ¶
func (*HTTPProxy) IsAvailable ¶
func (*HTTPProxy) ServeHTTP ¶
func (p *HTTPProxy) ServeHTTP(ctx context.Context, c *app.RequestContext)
func (*HTTPProxy) SetDirector ¶
SetDirector use to customize protocol.Request
func (*HTTPProxy) SetErrorHandler ¶
func (p *HTTPProxy) SetErrorHandler(eh func(c *app.RequestContext, err error))
SetErrorHandler use to customize error handler