Documentation ¶
Index ¶
- Variables
- func ClientDo() clientBehavior
- func ClientDoDeadline(param time.Time) clientBehavior
- func ClientDoRedirects(param int) clientBehavior
- func ClientDoTimeout(param time.Duration) clientBehavior
- func JoinURLPath(req *protocol.Request, target string) (path []byte)
- type Director
- type Option
- type Options
- type ReverseProxy
- func (r *ReverseProxy) ServeHTTP(c context.Context, ctx *app.RequestContext)
- func (r *ReverseProxy) SetClient(client *client.Client)
- func (r *ReverseProxy) SetClientBehavior(cb clientBehavior)
- func (r *ReverseProxy) SetDirector(director func(req *protocol.Request))
- func (r *ReverseProxy) SetErrorHandler(eh func(c *app.RequestContext, err error))
- func (r *ReverseProxy) SetModifyResponse(mr func(*protocol.Response) error)
- func (r *ReverseProxy) SetSaveOriginResHeader(b bool)
- func (r *ReverseProxy) SetTransferTrailer(b bool)
- type WSReverseProxy
Constants ¶
This section is empty.
Variables ¶
var DefaultOptions = &Options{ Director: nil, Dialer: websocket.DefaultDialer, Upgrader: &hzws.HertzUpgrader{ ReadBufferSize: 1024, WriteBufferSize: 1024, }, }
Functions ¶
func ClientDoDeadline ¶ added in v1.0.6
func ClientDoRedirects ¶ added in v1.0.6
func ClientDoRedirects(param int) clientBehavior
func ClientDoTimeout ¶ added in v1.0.6
Types ¶
type Option ¶ added in v0.1.4
type Option func(o *Options)
func WithDialer ¶ added in v0.1.4
WithDialer for dialer customization
func WithDirector ¶ added in v0.1.4
WithDirector user can edit the forward header by using custom Director NOTE: custom Director will overwrite default forward header field if they have the same key
func WithUpgrader ¶ added in v0.1.4
func WithUpgrader(upgrader *hzws.HertzUpgrader) Option
WithUpgrader for upgrader customization
type Options ¶ added in v0.1.4
type Options struct { Director Director Dialer *websocket.Dialer Upgrader *hzws.HertzUpgrader }
type ReverseProxy ¶
type ReverseProxy struct { // target is set as a reverse proxy address Target string // contains filtered or unexported fields }
func NewSingleHostReverseProxy ¶
func NewSingleHostReverseProxy(target string, options ...config.ClientOption) (*ReverseProxy, error)
NewSingleHostReverseProxy returns a new ReverseProxy that routes URLs to the scheme, host, and base path provided in target. If the target's path is "/base" and the incoming request was for "/dir", the target request will be for /base/dir. NewSingleHostReverseProxy does not rewrite the Host header. To rewrite Host headers, use ReverseProxy directly with a custom director policy.
When passing config.ClientOption it will initialize a local client.Client instance. Using ReverseProxy.SetClient if there is need for shared customized client.Client instance.
func (*ReverseProxy) ServeHTTP ¶
func (r *ReverseProxy) ServeHTTP(c context.Context, ctx *app.RequestContext)
func (*ReverseProxy) SetClient ¶
func (r *ReverseProxy) SetClient(client *client.Client)
SetClient use to customize client
func (*ReverseProxy) SetClientBehavior ¶ added in v1.0.6
func (r *ReverseProxy) SetClientBehavior(cb clientBehavior)
func (*ReverseProxy) SetDirector ¶
func (r *ReverseProxy) SetDirector(director func(req *protocol.Request))
SetDirector use to customize protocol.Request
func (*ReverseProxy) SetErrorHandler ¶
func (r *ReverseProxy) SetErrorHandler(eh func(c *app.RequestContext, err error))
SetErrorHandler use to customize error handler
func (*ReverseProxy) SetModifyResponse ¶
func (r *ReverseProxy) SetModifyResponse(mr func(*protocol.Response) error)
SetModifyResponse use to modify response
func (*ReverseProxy) SetSaveOriginResHeader ¶ added in v0.1.4
func (r *ReverseProxy) SetSaveOriginResHeader(b bool)
func (*ReverseProxy) SetTransferTrailer ¶ added in v0.1.4
func (r *ReverseProxy) SetTransferTrailer(b bool)
type WSReverseProxy ¶ added in v0.1.4
type WSReverseProxy struct {
// contains filtered or unexported fields
}
func NewWSReverseProxy ¶ added in v0.1.4
func NewWSReverseProxy(target string, opts ...Option) *WSReverseProxy
NewWSReverseProxy new a proxy which will provide handler for websocket reverse proxy
func (*WSReverseProxy) ServeHTTP ¶ added in v0.1.4
func (w *WSReverseProxy) ServeHTTP(ctx context.Context, c *app.RequestContext)
ServeHTTP provides websocket reverse proxy service