http

package
v0.0.0-...-d35968a Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
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

func IsASCIIPrint(s string) bool

IsASCIIPrint returns whether s is ASCII and printable according to https://tools.ietf.org/html/rfc20#section-4.2.

func JoinURLPath

func JoinURLPath(req *protocol.Request, target string) (path []byte)

func New

func New(opts Options, client *client.Client) (proxy.Proxy, error)

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.

func NewClient

func NewClient(opts ClientOptions) (*client.Client, error)

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 (p *HTTPProxy) AddFailedCount(count uint) error

func (*HTTPProxy) ID

func (p *HTTPProxy) ID() string

ID return proxy's ID

func (*HTTPProxy) IsAvailable

func (p *HTTPProxy) IsAvailable() bool

func (*HTTPProxy) ServeHTTP

func (p *HTTPProxy) ServeHTTP(c context.Context, ctx *app.RequestContext)

func (*HTTPProxy) SetClient

func (p *HTTPProxy) SetClient(client *client.Client)

SetClient use to customize client

func (*HTTPProxy) SetDirector

func (p *HTTPProxy) SetDirector(director func(req *protocol.Request))

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

func (*HTTPProxy) SetTransferTrailer

func (r *HTTPProxy) SetTransferTrailer(b bool)

func (*HTTPProxy) Target

func (p *HTTPProxy) Target() string

func (*HTTPProxy) Weight

func (p *HTTPProxy) Weight() uint

type Options

type Options struct {
	Target      string
	Protocol    config.Protocol
	Weight      uint
	MaxFails    uint
	FailTimeout time.Duration
}

Jump to

Keyboard shortcuts

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