當前位置: 首頁>>代碼示例>>Golang>>正文


Golang mux.APIContainer類代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/genericapiserver/mux.APIContainer的典型用法代碼示例。如果您正苦於以下問題:Golang APIContainer類的具體用法?Golang APIContainer怎麽用?Golang APIContainer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了APIContainer類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Install

func (l Logs) Install(c *mux.APIContainer) {
	// use restful: ws.Route(ws.GET("/logs/{logpath:*}").To(fileHandler))
	// See github.com/emicklei/go-restful/blob/master/examples/restful-serve-static.go
	ws := new(restful.WebService)
	ws.Path("/logs")
	ws.Doc("get log files")
	ws.Route(ws.GET("/{logpath:*}").To(logFileHandler).Param(ws.PathParameter("logpath", "path to the log").DataType("string")))
	ws.Route(ws.GET("/").To(logFileListHandler))

	c.Add(ws)
}
開發者ID:humblec,項目名稱:kubernetes,代碼行數:11,代碼來源:logs.go

示例2: initMetricsRoute

// initMetricsRoute initializes an HTTP endpoint for metrics.
func initMetricsRoute(apiContainer *genericmux.APIContainer, path string) {
	ws := new(restful.WebService).
		Path(path).
		Doc("return metrics for this process")
	h := prometheus.Handler()
	ws.Route(ws.GET("/").To(func(req *restful.Request, resp *restful.Response) {
		h.ServeHTTP(resp.ResponseWriter, req.Request)
	}).Doc("return metrics for this process").
		Returns(http.StatusOK, "if metrics are available", nil).
		Produces("text/plain"))

	apiContainer.Add(ws)
}
開發者ID:xgwang-zte,項目名稱:origin,代碼行數:14,代碼來源:master.go

示例3: Install

// Install registers the APIServer's `/version` handler.
func (v Version) Install(c *mux.APIContainer) {
	// Set up a service to return the git code version.
	versionWS := new(restful.WebService)
	versionWS.Path("/version")
	versionWS.Doc("git code version from which this is built")
	versionWS.Route(
		versionWS.GET("/").To(handleVersion).
			Doc("get the code version").
			Operation("getCodeVersion").
			Produces(restful.MIME_JSON).
			Consumes(restful.MIME_JSON).
			Writes(version.Info{}))

	c.Add(versionWS)
}
開發者ID:ncdc,項目名稱:kubernetes,代碼行數:16,代碼來源:version.go

示例4: Install

// Install adds the SwaggerUI webservice to the given mux.
func (s Swagger) Install(c *mux.APIContainer) {
	swagger.RegisterSwaggerService(swagger.Config{
		WebServicesUrl:  "https://" + s.ExternalAddress,
		WebServices:     c.RegisteredWebServices(),
		ApiPath:         "/swaggerapi/",
		SwaggerPath:     "/swaggerui/",
		SwaggerFilePath: "/swagger-ui/",
		SchemaFormatHandler: func(typeName string) string {
			switch typeName {
			case "metav1.Time", "*metav1.Time":
				return "date-time"
			}
			return ""
		},
	}, c.Container)
}
開發者ID:alex-mohr,項目名稱:kubernetes,代碼行數:17,代碼來源:swagger.go

示例5: initAPIVersionRoute

// initAPIVersionRoute initializes the osapi endpoint to behave similar to the upstream api endpoint
func initAPIVersionRoute(apiContainer *genericmux.APIContainer, prefix string, versions ...string) {
	versionHandler := apiserver.APIVersionHandler(kapi.Codecs, func(req *restful.Request) *unversioned.APIVersions {
		apiVersionsForDiscovery := unversioned.APIVersions{
			// TODO: ServerAddressByClientCIDRs: s.getServerAddressByClientCIDRs(req.Request),
			Versions: versions,
		}
		return &apiVersionsForDiscovery
	})
	ws := new(restful.WebService).
		Path(prefix).
		Doc("list supported server API versions")
	ws.Route(ws.GET("/").To(versionHandler).
		Doc("list supported server API versions").
		Produces(restful.MIME_JSON).
		Consumes(restful.MIME_JSON).
		Operation("get" + strings.Title(prefix[1:]) + "Version"))
	apiContainer.Add(ws)
}
開發者ID:xgwang-zte,項目名稱:origin,代碼行數:19,代碼來源:master.go

示例6: initReadinessCheckRoute

// initReadinessCheckRoute initializes an HTTP endpoint for readiness checking
func initReadinessCheckRoute(apiContainer *genericmux.APIContainer, path string, readyFunc func() bool) {
	ws := new(restful.WebService).
		Path(path).
		Doc("return the readiness state of the master")
	ws.Route(ws.GET("/").To(func(req *restful.Request, resp *restful.Response) {
		if readyFunc() {
			resp.ResponseWriter.WriteHeader(http.StatusOK)
			resp.ResponseWriter.Write([]byte("ok"))

		} else {
			resp.ResponseWriter.WriteHeader(http.StatusServiceUnavailable)
		}
	}).Doc("return the readiness state of the master").
		Returns(http.StatusOK, "if the master is ready", nil).
		Returns(http.StatusServiceUnavailable, "if the master is not ready", nil).
		Produces(restful.MIME_JSON))

	apiContainer.Add(ws)
}
開發者ID:xgwang-zte,項目名稱:origin,代碼行數:20,代碼來源:master.go

示例7: Install

// Install adds the Index webservice to the given mux.
func (i Index) Install(c *mux.APIContainer) {
	c.UnlistedRoutes.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, c.NonSwaggerRoutes.HandledPaths()...)
		sort.Strings(handledPaths)
		responsewriters.WriteRawJSON(status, metav1.RootPaths{Paths: handledPaths}, w)
	})
}
開發者ID:sebrandon1,項目名稱:kubernetes,代碼行數:20,代碼來源:index.go

示例8: Install

// Install adds the SwaggerUI webservice to the given mux.
func (oa OpenAPI) Install(c *mux.APIContainer) {
	err := openapi.RegisterOpenAPIService("/swagger.json", c.RegisteredWebServices(), oa.Config, c)
	if err != nil {
		glog.Fatalf("Failed to register open api spec for root: %v", err)
	}
}
開發者ID:eljefedelrodeodeljefe,項目名稱:kubernetes,代碼行數:7,代碼來源:openapi.go

示例9: Install

// Install adds the SwaggerUI webservice to the given mux.
func (s Swagger) Install(c *mux.APIContainer) {
	s.Config.WebServices = c.RegisteredWebServices()
	swagger.RegisterSwaggerService(*s.Config, c.Container)
}
開發者ID:nak3,項目名稱:kubernetes,代碼行數:5,代碼來源:swagger.go


注:本文中的k8s/io/kubernetes/pkg/genericapiserver/mux.APIContainer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。