本文整理汇总了Golang中k8s/io/kubernetes/pkg/apiserver.PathRecorderMux.BaseMux方法的典型用法代码示例。如果您正苦于以下问题:Golang PathRecorderMux.BaseMux方法的具体用法?Golang PathRecorderMux.BaseMux怎么用?Golang PathRecorderMux.BaseMux使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/apiserver.PathRecorderMux
的用法示例。
在下文中一共展示了PathRecorderMux.BaseMux方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Install
func (i Index) Install(mux *apiserver.PathRecorderMux, c *restful.Container) {
mux.BaseMux().HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
status := http.StatusOK
if r.URL.Path != "/" && r.URL.Path != "/index.html" {
// Since "/" matches all paths, handleIndex is called for all paths for which there is no handler registered.
// We want to return a 404 status with a list of all valid paths, incase of an invalid URL request.
status = http.StatusNotFound
}
var handledPaths []string
// Extract the paths handled using restful.WebService
for _, ws := range c.RegisteredWebServices() {
handledPaths = append(handledPaths, ws.RootPath())
}
// Extract the paths handled using mux handler.
handledPaths = append(handledPaths, mux.HandledPaths()...)
sort.Strings(handledPaths)
apiserver.WriteRawJSON(status, unversioned.RootPaths{Paths: handledPaths}, w)
})
}
示例2: Install
// Install adds the Profiling webservice to the given mux.
func (d Profiling) Install(mux *apiserver.PathRecorderMux, c *restful.Container) {
mux.BaseMux().HandleFunc("/debug/pprof/", pprof.Index)
mux.BaseMux().HandleFunc("/debug/pprof/profile", pprof.Profile)
mux.BaseMux().HandleFunc("/debug/pprof/symbol", pprof.Symbol)
}