mirror of https://github.com/docker/docs.git
Merge pull request #2102 from nishanttotla/fix-httpclientandscheme-signature
Returning and handling error from HTTPClientAndScheme
This commit is contained in:
commit
6404badef1
|
@ -484,9 +484,9 @@ func getContainerJSON(c *context, w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
client, scheme := container.Engine.HTTPClientAndScheme()
|
||||
if client == nil {
|
||||
httpError(w, "Cannot connect to docker engine", http.StatusInternalServerError)
|
||||
client, scheme, err := container.Engine.HTTPClientAndScheme()
|
||||
if err != nil {
|
||||
httpError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -814,9 +814,9 @@ func postContainersExec(c *context, w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
client, scheme := container.Engine.HTTPClientAndScheme()
|
||||
if client == nil {
|
||||
httpError(w, "Cannot connect to docker engine", http.StatusInternalServerError)
|
||||
client, scheme, err := container.Engine.HTTPClientAndScheme()
|
||||
if err != nil {
|
||||
httpError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,11 @@ func proxyAsync(engine *cluster.Engine, w http.ResponseWriter, r *http.Request,
|
|||
// RequestURI may not be sent to client
|
||||
r.RequestURI = ""
|
||||
|
||||
client, scheme := engine.HTTPClientAndScheme()
|
||||
client, scheme, err := engine.HTTPClientAndScheme()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r.URL.Scheme = scheme
|
||||
r.URL.Host = engine.Addr
|
||||
|
|
|
@ -147,11 +147,11 @@ func NewEngine(addr string, overcommitRatio float64, opts *EngineOpts) *Engine {
|
|||
}
|
||||
|
||||
// HTTPClientAndScheme returns the underlying HTTPClient and the scheme used by the engine
|
||||
func (e *Engine) HTTPClientAndScheme() (*http.Client, string) {
|
||||
func (e *Engine) HTTPClientAndScheme() (*http.Client, string, error) {
|
||||
if dc, ok := e.client.(*dockerclient.DockerClient); ok {
|
||||
return dc.HTTPClient, dc.URL.Scheme
|
||||
return dc.HTTPClient, dc.URL.Scheme, nil
|
||||
}
|
||||
return nil, ""
|
||||
return nil, "", fmt.Errorf("Possibly lost connection to Engine (name: %s, ID: %s) ", e.Name, e.ID)
|
||||
}
|
||||
|
||||
// Connect will initialize a connection to the Docker daemon running on the
|
||||
|
|
Loading…
Reference in New Issue