{"action":"created","issue":{"url":"https://api.github.com/repos/emicklei/go-restful/issues/274","repository_url":"https://api.github.com/repos/emicklei/go-restful","labels_url":"https://api.github.com/repos/emicklei/go-restful/issues/274/labels{/name}","comments_url":"https://api.github.com/repos/emicklei/go-restful/issues/274/comments","events_url":"https://api.github.com/repos/emicklei/go-restful/issues/274/events","html_url":"https://github.com/emicklei/go-restful/issues/274","id":146714307,"number":274,"title":"Container cannot remove the webservice completely","user":{"login":"uruddarraju","id":2271582,"avatar_url":"https://avatars.githubusercontent.com/u/2271582?v=3","gravatar_id":"","url":"https://api.github.com/users/uruddarraju","html_url":"https://github.com/uruddarraju","followers_url":"https://api.github.com/users/uruddarraju/followers","following_url":"https://api.github.com/users/uruddarraju/following{/other_user}","gists_url":"https://api.github.com/users/uruddarraju/gists{/gist_id}","starred_url":"https://api.github.com/users/uruddarraju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uruddarraju/subscriptions","organizations_url":"https://api.github.com/users/uruddarraju/orgs","repos_url":"https://api.github.com/users/uruddarraju/repos","events_url":"https://api.github.com/users/uruddarraju/events{/privacy}","received_events_url":"https://api.github.com/users/uruddarraju/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-07T18:58:33Z","updated_at":"2016-04-07T22:11:39Z","closed_at":null,"body":"We had an issue in kube while trying to remove a webservice and add it back to the container, that is captured here: https://github.com/kubernetes/kubernetes/issues/23831#\r\n\r\nWe noticed that the container.Remove() [[here](https://github.com/emicklei/go-restful/blob/master/container.go#L129)] function only removes the webservice from the registered webservices list but does not undo the HandleFunc call it does during Add ([here](https://github.com/emicklei/go-restful/blob/master/container.go#L107)) which populates the net/http ServeMux.m map, so after a remove net/http server.go still maintains a map of the routes to the handler functions, that is not cleaned up during a delete. So if we remove a webservice from a container and try to add it back, it fails with the panic `multiple registrations found`\r\n\r\nWas able to reproduce the issue today, where I was able to successfully add a webservice to a container, remove it and when I add it back, I see the following issue:\r\n\r\n```\r\npanic: http: multiple registrations for /users\r\n```\r\n\r\nI tried the example here: https://github.com/emicklei/go-restful/blob/master/examples/restful-user-resource.go. And changed the lines https://github.com/emicklei/go-restful/blob/master/examples/restful-user-resource.go#L74 to do,\r\n\r\n```\r\n\tcontainer.Add(ws)\r\n\tcontainer.Remove(ws)\r\n\tcontainer.Add(ws)\r\n```\r\n\r\nThis created the panic above. Can you suggest if there is something else we can do or how can this be solved ? \r\n\r\n"},"comment":{"url":"https://api.github.com/repos/emicklei/go-restful/issues/comments/207111403","html_url":"https://github.com/emicklei/go-restful/issues/274#issuecomment-207111403","issue_url":"https://api.github.com/repos/emicklei/go-restful/issues/274","id":207111403,"user":{"login":"lavalamp","id":647318,"avatar_url":"https://avatars.githubusercontent.com/u/647318?v=3","gravatar_id":"","url":"https://api.github.com/users/lavalamp","html_url":"https://github.com/lavalamp","followers_url":"https://api.github.com/users/lavalamp/followers","following_url":"https://api.github.com/users/lavalamp/following{/other_user}","gists_url":"https://api.github.com/users/lavalamp/gists{/gist_id}","starred_url":"https://api.github.com/users/lavalamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lavalamp/subscriptions","organizations_url":"https://api.github.com/users/lavalamp/orgs","repos_url":"https://api.github.com/users/lavalamp/repos","events_url":"https://api.github.com/users/lavalamp/events{/privacy}","received_events_url":"https://api.github.com/users/lavalamp/received_events","type":"User","site_admin":false},"created_at":"2016-04-07T22:11:39Z","updated_at":"2016-04-07T22:11:39Z","body":"@emicklei That was basically my conclusion as well.\r\n\r\nRemove should probably just return an error if you're using the default serve mux?"}}