Merge branch '20610-installer-load-balancer'. Refs #20610
[arvados.git] / sdk / go / arvadostest / proxy.go
index 48700d8b186d8fd4d104ed820a6d3060772a86bc..9940ddd3d96404552282b5e6b8e887c31b3a1862 100644 (file)
@@ -26,6 +26,10 @@ type Proxy struct {
 
        // A dump of each request that has been proxied.
        RequestDumps [][]byte
+
+       // If non-nil, func will be called on each incoming request
+       // before proxying it.
+       Director func(*http.Request)
 }
 
 // NewProxy returns a new Proxy that saves a dump of each reqeust
@@ -63,6 +67,9 @@ func NewProxy(c *check.C, svc arvados.Service) *Proxy {
                URL:    u,
        }
        rp.Director = func(r *http.Request) {
+               if proxy.Director != nil {
+                       proxy.Director(r)
+               }
                dump, _ := httputil.DumpRequest(r, true)
                proxy.RequestDumps = append(proxy.RequestDumps, dump)
                r.URL.Scheme = target.Scheme