From f025b6ea360c32ba318afb69e013b1ee8de8a40f Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Mon, 8 Jun 2015 22:26:50 +0100 Subject: [PATCH] refactor interceptor invocation --- proxy/proxy.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index c351fac5..1911fba8 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -84,19 +84,17 @@ func NewProxy(c Config) (*Proxy, error) { func (proxy *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { Info.Printf("%s %s", r.Method, r.URL) path := r.URL.Path + var i interceptor switch { case containerCreateRegexp.MatchString(path): - proxy.serveWithInterceptor(&createContainerInterceptor{proxy.client, proxy.dockerBridgeIP, proxy.WithDNS, proxy.WithIPAM}, w, r) + i = &createContainerInterceptor{proxy.client, proxy.dockerBridgeIP, proxy.WithDNS, proxy.WithIPAM} case containerStartRegexp.MatchString(path): - proxy.serveWithInterceptor(&startContainerInterceptor{proxy.client, proxy.WithDNS, proxy.WithIPAM}, w, r) + i = &startContainerInterceptor{proxy.client, proxy.WithDNS, proxy.WithIPAM} case execCreateRegexp.MatchString(path): - proxy.serveWithInterceptor(&createExecInterceptor{proxy.client, proxy.WithIPAM}, w, r) + i = &createExecInterceptor{proxy.client, proxy.WithIPAM} default: - proxy.serveWithInterceptor(&nullInterceptor{}, w, r) + i = &nullInterceptor{} } -} - -func (proxy *Proxy) serveWithInterceptor(i interceptor, w http.ResponseWriter, r *http.Request) { newClient(proxy.dial, i).ServeHTTP(w, r) }