Skip to content

Instantly share code, notes, and snippets.

@jochasinga
Created April 5, 2016 15:36
Show Gist options
  • Save jochasinga/40be3157baea15a41b52d82ccaf2bf84 to your computer and use it in GitHub Desktop.
Save jochasinga/40be3157baea15a41b52d82ccaf2bf84 to your computer and use it in GitHub Desktop.
Proxy behing another Proxy in Relay
// Each hop to the test server takes 1 second
delay := time.Duration(1) * time.Second
ts := httptest.NewServer(http.HandlerFunc(handler))
p3 := relay.NewProxy(delay, ts)
p2 := relay.NewProxy(delay, p3)
p1 := relay.NewProxy(delay, p2)
start := time.Now()
resp, _ := client.Get(p1.URL)
elapsed := time.Since(start)
So(elapsed, ShouldAlmostEqual, time.Duration(6) * time.Second)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment