refactor interceptor invocation

This commit is contained in:
Matthias Radestock committed 2015-06-09 14:45:42 +01:00
1 parent 03fa95fcb5
commit f025b6ea36
1 file changed
+5 -7
+5 -7
View File
@@ -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)
}