From ed1b30aa2ceb323f2b3fb6ca275e27babc2e7f55 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Mon, 22 Jul 2024 12:34:42 -0400 Subject: [PATCH] proxy components naming (#704) --- endpoints/proxy/backend.go | 2 +- endpoints/proxy/frontend.go | 2 +- endpoints/publicProxy/http.go | 4 ++-- util/proxy.go | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/endpoints/proxy/backend.go b/endpoints/proxy/backend.go index 1aef09e9..9a22ce00 100644 --- a/endpoints/proxy/backend.go +++ b/endpoints/proxy/backend.go @@ -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, diff --git a/endpoints/proxy/frontend.go b/endpoints/proxy/frontend.go index bd31b36b..9660270e 100644 --- a/endpoints/proxy/frontend.go +++ b/endpoints/proxy/frontend.go @@ -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, diff --git a/endpoints/publicProxy/http.go b/endpoints/publicProxy/http.go index 60fc4438..f32736bb 100644 --- a/endpoints/publicProxy/http.go +++ b/endpoints/publicProxy/http.go @@ -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 != "" { diff --git a/util/proxy.go b/util/proxy.go index 8991fecd..a585a603 100644 --- a/util/proxy.go +++ b/util/proxy.go @@ -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) }