review feedback

This commit is contained in:
Paul Bellamy committed 2015-09-22 15:09:32 +01:00
1 parent 74c3b0d079
commit 3e4d8a3ffe
5 files changed
+29 -17

No files matched your search

-5
View File
@@ -50,10 +50,6 @@ func unmarshalRequestBody(r *http.Request, target interface{}) error {
}
r.Body = ioutil.NopCloser(bytes.NewReader(body))
if len(body) == 0 {
return nil
}
d := json.NewDecoder(bytes.NewReader(body))
d.UseNumber() // don't want large numbers in scientific format
return d.Decode(&target)
@@ -66,7 +62,6 @@ func marshalRequestBody(r *http.Request, body interface{}) error {
}
r.Body = ioutil.NopCloser(bytes.NewReader(newBody))
r.ContentLength = int64(len(newBody))
r.Header.Set("Content-Type", "application/json")
return nil
}
+4
View File
@@ -396,6 +396,10 @@ func (proxy *Proxy) setWeaveDNS(hostConfig *docker.HostConfig, hostname, dnsDoma
}
func (proxy *Proxy) getDNSDomain() (domain string, running bool) {
if proxy.WithoutDNS {
return "", false
}
domain = nameserver.DefaultDomain
running = proxy.WithDNS
weaveContainer, err := proxy.client.InspectContainer("weave")
+6 -3
View File
@@ -14,11 +14,11 @@ type startContainerRequestBody struct {
func (i *startContainerInterceptor) InterceptRequest(r *http.Request) error {
container, err := inspectContainerInPath(i.proxy.client, r.URL.Path)
if err != nil || !containerShouldAttach(container) {
if err != nil {
return err
}
if r.Header.Get("Content-Type") != "application/json" {
if !containerShouldAttach(container) || r.Header.Get("Content-Type") != "application/json" {
i.proxy.createWait(r, container.ID)
return nil
}
@@ -35,8 +35,11 @@ func (i *startContainerInterceptor) InterceptRequest(r *http.Request) error {
}
}
if err := marshalRequestBody(r, hostConfig); err != nil {
return err
}
i.proxy.createWait(r, container.ID)
return marshalRequestBody(r, hostConfig)
return nil
}
func (i *startContainerInterceptor) InterceptResponse(r *http.Response) error {