Merge pull request #28937 from ping035627/ping035627-patch-0714

Automatic merge from submit-queue

Optimise the New function in genericapiserver.go

It needn't the handlerContainer variable in the "New" function when deal s.HandlerContainer, I think, and it seems the codes more concise.
pull/6/head
k8s-merge-robot 2016-07-14 19:56:00 -07:00 committed by GitHub
commit c481291320
1 changed files with 2 additions and 4 deletions

View File

@ -372,16 +372,14 @@ func New(c *Config) (*GenericAPIServer, error) {
apiGroupsForDiscovery: map[string]unversioned.APIGroup{},
}
var handlerContainer *restful.Container
if c.RestfulContainer != nil {
s.mux = c.RestfulContainer.ServeMux
handlerContainer = c.RestfulContainer
s.HandlerContainer = c.RestfulContainer
} else {
mux := http.NewServeMux()
s.mux = mux
handlerContainer = NewHandlerContainer(mux, c.Serializer)
s.HandlerContainer = NewHandlerContainer(mux, c.Serializer)
}
s.HandlerContainer = handlerContainer
// Use CurlyRouter to be able to use regular expressions in paths. Regular expressions are required in paths for example for proxy (where the path is proxy/{kind}/{name}/{*})
s.HandlerContainer.Router(restful.CurlyRouter{})
s.MuxHelper = &apiserver.MuxHelper{Mux: s.mux, RegisteredPaths: []string{}}