コード例 #1
0
func (l SwaggerUI) Install(mux *apiserver.PathRecorderMux, c *restful.Container) {
	fileServer := http.FileServer(&assetfs.AssetFS{
		Asset:    swagger.Asset,
		AssetDir: swagger.AssetDir,
		Prefix:   "third_party/swagger-ui",
	})
	prefix := "/swagger-ui/"
	mux.Handle(prefix, http.StripPrefix(prefix, fileServer))
}
コード例 #2
0
ファイル: metrics.go プロジェクト: bryk/kubernetes
func (m MetricsWithReset) Install(mux *apiserver.PathRecorderMux, c *restful.Container) {
	defaultMetricsHandler := prometheus.Handler().ServeHTTP
	mux.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) {
		if req.Method == "DELETE" {
			apiservermetrics.Reset()
			etcdmetrics.Reset()
			io.WriteString(w, "metrics reset\n")
			return
		}
		defaultMetricsHandler(w, req)
	})
}
コード例 #3
0
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)
	})
}
コード例 #4
0
ファイル: metrics.go プロジェクト: bryk/kubernetes
func (m DefaultMetrics) Install(mux *apiserver.PathRecorderMux, c *restful.Container) {
	mux.HandleFunc("/metrics", prometheus.Handler().ServeHTTP)
}
コード例 #5
0
ファイル: profiling.go プロジェクト: bryk/kubernetes
// 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)
}
コード例 #6
0
ファイル: ui.go プロジェクト: bryk/kubernetes
func (r UIRedirect) Install(mux *apiserver.PathRecorderMux, c *restful.Container) {
	mux.HandleFunc("/ui/", func(w http.ResponseWriter, r *http.Request) {
		http.Redirect(w, r, dashboardPath, http.StatusTemporaryRedirect)
	})
}