Documentation ¶
Index ¶
- Constants
- Variables
- func GetHTTPSHostname(c net.Conn) (_ net.Conn, _ map[string]string, err error)
- func NotFoundResponse() *http.Response
- type ByLocation
- type ChooseEndpointFunc
- type CreateConnByEndpointFunc
- type CreateConnFunc
- type HTTPReverseProxy
- func (rp *HTTPReverseProxy) CheckAuth(domain, location, routeByHTTPUser, user, passwd string) bool
- func (rp *HTTPReverseProxy) CreateConnection(reqRouteInfo *RequestRouteInfo, byEndpoint bool) (net.Conn, error)
- func (rp *HTTPReverseProxy) GetHeaders(domain, location, routeByHTTPUser string) (headers map[string]string)
- func (rp *HTTPReverseProxy) GetRouteConfig(domain, location, routeByHTTPUser string) *RouteConfig
- func (rp *HTTPReverseProxy) Register(routeCfg RouteConfig) error
- func (rp *HTTPReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func (rp *HTTPReverseProxy) UnRegister(routeCfg RouteConfig)
- type HTTPReverseProxyOptions
- type HTTPSMuxer
- type Listener
- type Muxer
- func (v *Muxer) Listen(ctx context.Context, cfg *RouteConfig) (l *Listener, err error)
- func (v *Muxer) SetCheckAuthFunc(f authFunc) *Muxer
- func (v *Muxer) SetFailHookFunc(f failHookFunc) *Muxer
- func (v *Muxer) SetRewriteHostFunc(f hostRewriteFunc) *Muxer
- func (v *Muxer) SetSuccessHookFunc(f successHookFunc) *Muxer
- type RequestRouteInfo
- type RouteConfig
- type RouteInfo
- type Router
- type Routers
Constants ¶
View Source
const (
NotFound = `` /* 487-byte string literal not displayed */
)
Variables ¶
View Source
var ErrNoRouteFound = errors.New("no route found")
View Source
var ErrRouterConfigConflict = errors.New("router config conflict")
View Source
var NotFoundPagePath = ""
Functions ¶
func GetHTTPSHostname ¶
func NotFoundResponse ¶
Types ¶
type ByLocation ¶
type ByLocation []*Router
sort by location
func (ByLocation) Len ¶
func (a ByLocation) Len() int
func (ByLocation) Less ¶
func (a ByLocation) Less(i, j int) bool
func (ByLocation) Swap ¶
func (a ByLocation) Swap(i, j int)
type ChooseEndpointFunc ¶
type HTTPReverseProxy ¶
type HTTPReverseProxy struct {
// contains filtered or unexported fields
}
func NewHTTPReverseProxy ¶
func NewHTTPReverseProxy(option HTTPReverseProxyOptions, vhostRouter *Routers) *HTTPReverseProxy
func (*HTTPReverseProxy) CheckAuth ¶
func (rp *HTTPReverseProxy) CheckAuth(domain, location, routeByHTTPUser, user, passwd string) bool
func (*HTTPReverseProxy) CreateConnection ¶
func (rp *HTTPReverseProxy) CreateConnection(reqRouteInfo *RequestRouteInfo, byEndpoint bool) (net.Conn, error)
CreateConnection create a new connection by route config
func (*HTTPReverseProxy) GetHeaders ¶
func (rp *HTTPReverseProxy) GetHeaders(domain, location, routeByHTTPUser string) (headers map[string]string)
func (*HTTPReverseProxy) GetRouteConfig ¶
func (rp *HTTPReverseProxy) GetRouteConfig(domain, location, routeByHTTPUser string) *RouteConfig
func (*HTTPReverseProxy) Register ¶
func (rp *HTTPReverseProxy) Register(routeCfg RouteConfig) error
Register register the route config to reverse proxy reverse proxy will use CreateConnFn from routeCfg to create a connection to the remote service
func (*HTTPReverseProxy) ServeHTTP ¶
func (rp *HTTPReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)
func (*HTTPReverseProxy) UnRegister ¶
func (rp *HTTPReverseProxy) UnRegister(routeCfg RouteConfig)
UnRegister unregister route config by domain and location
type HTTPReverseProxyOptions ¶
type HTTPReverseProxyOptions struct {
ResponseHeaderTimeoutS int64
}
type Muxer ¶
type Muxer struct {
// contains filtered or unexported fields
}
Muxer is a functional component used for https and tcpmux proxies. It accepts connections and extracts vhost information from the beginning of the connection data. It then routes the connection to its appropriate listener.
func (*Muxer) Listen ¶
listen for a new domain name, if rewriteHost is not empty and rewriteHost func is not nil, then rewrite the host header to rewriteHost
func (*Muxer) SetCheckAuthFunc ¶
func (*Muxer) SetFailHookFunc ¶
func (*Muxer) SetRewriteHostFunc ¶
func (*Muxer) SetSuccessHookFunc ¶
type RequestRouteInfo ¶
type RouteConfig ¶
type RouteConfig struct { Domain string Location string RewriteHost string Username string Password string Headers map[string]string RouteByHTTPUser string CreateConnFn CreateConnFunc ChooseEndpointFn ChooseEndpointFunc CreateConnByEndpointFn CreateConnByEndpointFunc }
RouteConfig is the params used to match HTTP requests
Click to show internal directories.
Click to hide internal directories.