mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
optimise the New function
Signed-off-by: PingWang <wang.ping5@zte.com.cn>
This commit is contained in:
parent
8f08cb3391
commit
97b4a6fa42
@ -372,16 +372,14 @@ func New(c *Config) (*GenericAPIServer, error) {
|
|||||||
apiGroupsForDiscovery: map[string]unversioned.APIGroup{},
|
apiGroupsForDiscovery: map[string]unversioned.APIGroup{},
|
||||||
}
|
}
|
||||||
|
|
||||||
var handlerContainer *restful.Container
|
|
||||||
if c.RestfulContainer != nil {
|
if c.RestfulContainer != nil {
|
||||||
s.mux = c.RestfulContainer.ServeMux
|
s.mux = c.RestfulContainer.ServeMux
|
||||||
handlerContainer = c.RestfulContainer
|
s.HandlerContainer = c.RestfulContainer
|
||||||
} else {
|
} else {
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
s.mux = mux
|
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}/{*})
|
// 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.HandlerContainer.Router(restful.CurlyRouter{})
|
||||||
s.MuxHelper = &apiserver.MuxHelper{Mux: s.mux, RegisteredPaths: []string{}}
|
s.MuxHelper = &apiserver.MuxHelper{Mux: s.mux, RegisteredPaths: []string{}}
|
||||||
|
Loading…
Reference in New Issue
Block a user