mirror of https://github.com/docker/docs.git
fix headers
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
parent
9fdb28ebd4
commit
32c135314d
|
@ -51,6 +51,7 @@ func getInfo(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
c.debug,
|
c.debug,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(info)
|
json.NewEncoder(w).Encode(info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +73,7 @@ func getVersion(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
Arch: runtime.GOARCH,
|
Arch: runtime.GOARCH,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(version)
|
json.NewEncoder(w).Encode(version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +114,8 @@ func getContainersJSON(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(sort.Reverse(ContainerSorter(out)))
|
sort.Sort(sort.Reverse(ContainerSorter(out)))
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(out)
|
json.NewEncoder(w).Encode(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +147,8 @@ func getContainerJSON(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// insert node IP
|
// insert node IP
|
||||||
data = bytes.Replace(data, []byte("\"HostIp\":\"0.0.0.0\""), []byte(fmt.Sprintf("\"HostIp\":%q", container.Node.IP)), -1)
|
data = bytes.Replace(data, []byte("\"HostIp\":\"0.0.0.0\""), []byte(fmt.Sprintf("\"HostIp\":%q", container.Node.IP)), -1)
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,6 +176,8 @@ func postContainersCreate(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
httpError(w, err.Error(), http.StatusInternalServerError)
|
httpError(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
fmt.Fprintf(w, "{%q:%q}", "Id", container.Id)
|
fmt.Fprintf(w, "{%q:%q}", "Id", container.Id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
12
api/utils.go
12
api/utils.go
|
@ -41,6 +41,16 @@ func getContainerFromVars(c *context, vars map[string]string) (*cluster.Containe
|
||||||
return nil, errors.New("Not found")
|
return nil, errors.New("Not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// from https://github.com/golang/go/blob/master/src/net/http/httputil/reverseproxy.go#L82
|
||||||
|
func copyHeader(dst, src http.Header) {
|
||||||
|
for k, vv := range src {
|
||||||
|
for _, v := range vv {
|
||||||
|
fmt.Println(k, v)
|
||||||
|
dst.Add(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func proxy(tlsConfig *tls.Config, container *cluster.Container, w http.ResponseWriter, r *http.Request) error {
|
func proxy(tlsConfig *tls.Config, container *cluster.Container, w http.ResponseWriter, r *http.Request) error {
|
||||||
// Use a new client for each request
|
// Use a new client for each request
|
||||||
client, scheme := newClientAndScheme(tlsConfig)
|
client, scheme := newClientAndScheme(tlsConfig)
|
||||||
|
@ -56,6 +66,8 @@ func proxy(tlsConfig *tls.Config, container *cluster.Container, w http.ResponseW
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copyHeader(w.Header(), resp.Header)
|
||||||
w.WriteHeader(resp.StatusCode)
|
w.WriteHeader(resp.StatusCode)
|
||||||
io.Copy(w, resp.Body)
|
io.Copy(w, resp.Body)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue