From e737f3277dd4917dc84d40cc76de1acd005367cc Mon Sep 17 00:00:00 2001 From: zdj6373 Date: Wed, 30 Nov 2016 17:40:57 +0800 Subject: [PATCH] Code optimization --- pkg/kubectl/proxy_server.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/kubectl/proxy_server.go b/pkg/kubectl/proxy_server.go index b837fc4038ea6..4ef7c62bfdb6a 100644 --- a/pkg/kubectl/proxy_server.go +++ b/pkg/kubectl/proxy_server.go @@ -97,18 +97,14 @@ func matchesRegexp(str string, regexps []*regexp.Regexp) bool { func (f *FilterServer) accept(method, path, host string) bool { if matchesRegexp(path, f.RejectPaths) { - glog.V(3).Infof("Filter rejecting %v %v %v", method, path, host) return false } if matchesRegexp(method, f.RejectMethods) { - glog.V(3).Infof("Filter rejecting %v %v %v", method, path, host) return false } if matchesRegexp(path, f.AcceptPaths) && matchesRegexp(host, f.AcceptHosts) { - glog.V(3).Infof("Filter accepting %v %v %v", method, path, host) return true } - glog.V(3).Infof("Filter rejecting %v %v %v", method, path, host) return false } @@ -131,9 +127,11 @@ func extractHost(header string) (host string) { func (f *FilterServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) { host := extractHost(req.Host) if f.accept(req.Method, req.URL.Path, host) { + glog.V(3).Infof("Filter accepting %v %v %v", req.Method, req.URL.Path, host) f.delegate.ServeHTTP(rw, req) return } + glog.V(3).Infof("Filter rejecting %v %v %v", req.Method, req.URL.Path, host) rw.WriteHeader(http.StatusForbidden) rw.Write([]byte("

Unauthorized

")) }