Documentation ¶
Index ¶
- func ListenAndServe(addr string, r Relayer) error
- func ListenAndServeTLS(addr string, r Relayer) error
- func NewRouter(r Relayer) http.Handler
- func NewServer(addr string, r Relayer) *http.Server
- func NewTLSServer(addr string, r Relayer) *http.Server
- type CertGetter
- type ErrorHandler
- type Relayer
- type Rewriter
- type RoundTipperOnErrorer
- type RoundTripper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶
ListenAndServe listens on the TCP network address addr and then proxies requests using Relayer r.
func ListenAndServeTLS ¶
ListenAndServeTLS acts identically to ListenAndServe, except that it expects HTTPS connections.
Types ¶
type CertGetter ¶
type CertGetter interface { // GetCertificate returns the TLS certificate for the given client hello info. GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error) }
type ErrorHandler ¶
type ErrorHandler interface { // ErrorHandler handles the error returned by the upstream. // If this method is not implemented, the error will be returned to the client. ErrorHandler(http.ResponseWriter, *http.Request, error) }
type Relayer ¶
type Relayer interface { // GetUpstream returns the upstream URL for the given request. // If upstream is not determined, nil may be returned // DO NOT modify the request in this method. GetUpstream(*http.Request) (*url.URL, error) }
Relayer is the interface of the implementation that determines the behavior of the reverse proxy
type Rewriter ¶
type Rewriter interface { // Rewrite rewrites the request before sending it to the upstream. // For example, you can set `X-Forwarded-*` header here using [httputil.ProxyRequest.SetXForwarded](https://pkg.go.dev/net/http/httputil#ProxyRequest.SetXForwarded) Rewrite(*httputil.ProxyRequest) error }
type RoundTipperOnErrorer ¶
type RoundTripper ¶
type RoundTripper interface { // RoundTrip performs the round trip of the request. // It is necessary to implement the functions that http.Transport is responsible for (e.g. MaxIdleConnsPerHost). RoundTrip(r *http.Request) (*http.Response, error) RoundTripOnError(r *http.Request) (*http.Response, error) }
Click to show internal directories.
Click to hide internal directories.