proxy should provide reasonable error when execing on a container which doesn't exist
This commit is contained in:
1 parent
e6b587ea8d
commit
610bc46970
1 file changed
+11
-8
+11
-8
@@ -27,14 +27,17 @@ func newClient(dial func() (net.Conn, error), i interceptor) *client {
|
||||
}
|
||||
|
||||
func (c *client) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
err := c.InterceptRequest(r)
|
||||
if err == docker.ErrNoSuchImage {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
http.Error(w, "Unable to intercept request", http.StatusInternalServerError)
|
||||
Warning.Print("Error intercepting request: ", err)
|
||||
if err := c.InterceptRequest(r); err != nil {
|
||||
_, isNoSuchContainer := err.(*docker.NoSuchContainer)
|
||||
switch {
|
||||
case isNoSuchContainer:
|
||||
http.Error(w, err.Error(), http.StatusNotFound)
|
||||
case err == docker.ErrNoSuchImage:
|
||||
http.Error(w, err.Error(), http.StatusNotFound)
|
||||
default:
|
||||
http.Error(w, "Unable to intercept request", http.StatusInternalServerError)
|
||||
Warning.Print("Error intercepting request: ", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user