proxy components naming (#704)

This commit is contained in:
Michael Quigley 2024-07-22 12:34:42 -04:00
parent ca9a2e7b7c
commit ed1b30aa2c
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
4 changed files with 9 additions and 9 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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 != "" {

View File

@ -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)
}