mirror of
https://github.com/openziti/zrok.git
synced 2024-11-24 09:03:23 +01:00
proxy components naming (#704)
This commit is contained in:
parent
ca9a2e7b7c
commit
ed1b30aa2c
@ -52,7 +52,7 @@ func NewBackend(cfg *BackendConfig) (*Backend, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
handler := util.NewProxyHandler(proxy)
|
||||
handler := util.NewRequestsWrapper(proxy)
|
||||
return &Backend{
|
||||
cfg: cfg,
|
||||
listener: listener,
|
||||
|
@ -68,7 +68,7 @@ func NewFrontend(cfg *FrontendConfig) (*Frontend, error) {
|
||||
}
|
||||
proxy.Transport = zTransport
|
||||
|
||||
handler := authHandler(cfg.ShrToken, util.NewProxyHandler(proxy), "zrok", cfg, zCtx)
|
||||
handler := authHandler(cfg.ShrToken, util.NewRequestsWrapper(proxy), "zrok", cfg, zCtx)
|
||||
return &Frontend{
|
||||
cfg: cfg,
|
||||
zCtx: zCtx,
|
||||
|
@ -73,7 +73,7 @@ func NewHTTP(cfg *Config) (*HttpFrontend, error) {
|
||||
if err := configureOauthHandlers(context.Background(), cfg, cfg.Tls != nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
handler := authHandler(util.NewProxyHandler(proxy), cfg, key, zCtx)
|
||||
handler := shareHandler(util.NewRequestsWrapper(proxy), cfg, key, zCtx)
|
||||
return &HttpFrontend{
|
||||
cfg: cfg,
|
||||
zCtx: zCtx,
|
||||
@ -151,7 +151,7 @@ func hostTargetReverseProxy(cfg *Config, ctx ziti.Context) *httputil.ReverseProx
|
||||
return &httputil.ReverseProxy{Director: director}
|
||||
}
|
||||
|
||||
func authHandler(handler http.Handler, pcfg *Config, key []byte, ctx ziti.Context) http.HandlerFunc {
|
||||
func shareHandler(handler http.Handler, pcfg *Config, key []byte, ctx ziti.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
shrToken := resolveService(pcfg.HostMatch, r.Host)
|
||||
if shrToken != "" {
|
||||
|
@ -6,13 +6,13 @@ import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
type proxyHandler struct {
|
||||
type requestsWrapper struct {
|
||||
proxy *httputil.ReverseProxy
|
||||
requests int32
|
||||
}
|
||||
|
||||
func NewProxyHandler(proxy *httputil.ReverseProxy) *proxyHandler {
|
||||
handler := &proxyHandler{proxy: proxy}
|
||||
func NewRequestsWrapper(proxy *httputil.ReverseProxy) *requestsWrapper {
|
||||
handler := &requestsWrapper{proxy: proxy}
|
||||
|
||||
director := proxy.Director
|
||||
proxy.Director = func(req *http.Request) {
|
||||
@ -23,10 +23,10 @@ func NewProxyHandler(proxy *httputil.ReverseProxy) *proxyHandler {
|
||||
return handler
|
||||
}
|
||||
|
||||
func (self *proxyHandler) Requests() int32 {
|
||||
func (self *requestsWrapper) Requests() int32 {
|
||||
return atomic.LoadInt32(&self.requests)
|
||||
}
|
||||
|
||||
func (self *proxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
func (self *requestsWrapper) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
self.proxy.ServeHTTP(w, r)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user