本文整理匯總了Golang中github.com/emicklei/go-restful.WebService.DELETE方法的典型用法代碼示例。如果您正苦於以下問題:Golang WebService.DELETE方法的具體用法?Golang WebService.DELETE怎麽用?Golang WebService.DELETE使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/emicklei/go-restful.WebService
的用法示例。
在下文中一共展示了WebService.DELETE方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: initControllerRoutes
// initControllerRoutes adds a web service endpoint for managing the execution
// state of the controllers.
func initControllerRoutes(root *restful.WebService, path string, canStart bool, plug plug.Plug) {
root.Route(root.GET(path).To(func(req *restful.Request, resp *restful.Response) {
if !canStart {
resp.ResponseWriter.WriteHeader(http.StatusMethodNotAllowed)
fmt.Fprintf(resp, "disabled")
return
}
if plug.IsStarted() {
resp.ResponseWriter.WriteHeader(http.StatusOK)
fmt.Fprintf(resp, "ok")
} else {
resp.ResponseWriter.WriteHeader(http.StatusAccepted)
fmt.Fprintf(resp, "waiting")
}
}).Doc("Check whether the controllers are running on this master").
Returns(http.StatusOK, "if controllers are running", nil).
Returns(http.StatusMethodNotAllowed, "if controllers are disabled", nil).
Returns(http.StatusAccepted, "if controllers are waiting to be started", nil).
Produces(restful.MIME_JSON))
root.Route(root.PUT(path).To(func(req *restful.Request, resp *restful.Response) {
if !canStart {
resp.ResponseWriter.WriteHeader(http.StatusMethodNotAllowed)
fmt.Fprintf(resp, "disabled")
return
}
plug.Start()
resp.ResponseWriter.WriteHeader(http.StatusOK)
fmt.Fprintf(resp, "ok")
}).Doc("Start controllers on this master").
Returns(http.StatusOK, "if controllers have started", nil).
Returns(http.StatusMethodNotAllowed, "if controllers are disabled", nil).
Produces(restful.MIME_JSON))
root.Route(root.DELETE(path).To(func(req *restful.Request, resp *restful.Response) {
resp.ResponseWriter.WriteHeader(http.StatusAccepted)
fmt.Fprintf(resp, "terminating")
plug.Stop()
}).Doc("Stop the master").
Returns(http.StatusAccepted, "if the master will stop", nil).
Produces(restful.MIME_JSON))
}
示例2: CreateHttpApiHandler
// Creates a new HTTP handler that handles all requests to the API of the backend.
func CreateHttpApiHandler(client *client.Client, heapsterClient HeapsterClient,
clientConfig clientcmd.ClientConfig) http.Handler {
apiHandler := ApiHandler{client, heapsterClient, clientConfig}
wsContainer := restful.NewContainer()
deployWs := new(restful.WebService)
deployWs.Filter(wsLogger)
deployWs.Path("/api/v1/appdeployments").
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)
deployWs.Route(
deployWs.POST("").
To(apiHandler.handleDeploy).
Reads(AppDeploymentSpec{}).
Writes(AppDeploymentSpec{}))
deployWs.Route(
deployWs.POST("/validate/name").
To(apiHandler.handleNameValidity).
Reads(AppNameValiditySpec{}).
Writes(AppNameValidity{}))
deployWs.Route(
deployWs.POST("/validate/protocol").
To(apiHandler.handleProtocolValidity).
Reads(ProtocolValiditySpec{}).
Writes(ProtocolValidity{}))
deployWs.Route(
deployWs.GET("/protocols").
To(apiHandler.handleGetAvailableProcotols).
Writes(Protocols{}))
wsContainer.Add(deployWs)
deployFromFileWs := new(restful.WebService)
deployFromFileWs.Path("/api/v1/appdeploymentfromfile").
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)
deployFromFileWs.Route(
deployFromFileWs.POST("").
To(apiHandler.handleDeployFromFile).
Reads(AppDeploymentFromFileSpec{}).
Writes(AppDeploymentFromFileResponse{}))
wsContainer.Add(deployFromFileWs)
replicationControllerWs := new(restful.WebService)
replicationControllerWs.Filter(wsLogger)
replicationControllerWs.Path("/api/v1/replicationcontrollers").
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)
replicationControllerWs.Route(
replicationControllerWs.GET("").
To(apiHandler.handleGetReplicationControllerList).
Writes(ReplicationControllerList{}))
replicationControllerWs.Route(
replicationControllerWs.GET("/{namespace}/{replicationController}").
To(apiHandler.handleGetReplicationControllerDetail).
Writes(ReplicationControllerDetail{}))
replicationControllerWs.Route(
replicationControllerWs.POST("/{namespace}/{replicationController}/update/pods").
To(apiHandler.handleUpdateReplicasCount).
Reads(ReplicationControllerSpec{}))
replicationControllerWs.Route(
replicationControllerWs.DELETE("/{namespace}/{replicationController}").
To(apiHandler.handleDeleteReplicationController))
replicationControllerWs.Route(
replicationControllerWs.GET("/pods/{namespace}/{replicationController}").
To(apiHandler.handleGetReplicationControllerPods).
Writes(ReplicationControllerPods{}))
wsContainer.Add(replicationControllerWs)
namespacesWs := new(restful.WebService)
namespacesWs.Filter(wsLogger)
namespacesWs.Path("/api/v1/namespaces").
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)
namespacesWs.Route(
namespacesWs.POST("").
To(apiHandler.handleCreateNamespace).
Reads(NamespaceSpec{}).
Writes(NamespaceSpec{}))
namespacesWs.Route(
namespacesWs.GET("").
To(apiHandler.handleGetNamespaces).
Writes(NamespaceList{}))
wsContainer.Add(namespacesWs)
logsWs := new(restful.WebService)
logsWs.Filter(wsLogger)
logsWs.Path("/api/v1/logs").
Produces(restful.MIME_JSON)
logsWs.Route(
logsWs.GET("/{namespace}/{podId}").
To(apiHandler.handleLogs).
Writes(Logs{}))
logsWs.Route(
logsWs.GET("/{namespace}/{podId}/{container}").
To(apiHandler.handleLogs).
Writes(Logs{}))
wsContainer.Add(logsWs)
//.........這裏部分代碼省略.........
示例3: CreateHttpApiHandler
// CreateHttpApiHandler creates a new HTTP handler that handles all requests to the API of the backend.
func CreateHttpApiHandler(client *client.Client, heapsterClient HeapsterClient,
clientConfig clientcmd.ClientConfig) http.Handler {
verber := common.NewResourceVerber(client.RESTClient, client.ExtensionsClient.RESTClient,
client.AppsClient.RESTClient, client.BatchClient.RESTClient)
apiHandler := ApiHandler{client, heapsterClient, clientConfig, verber}
wsContainer := restful.NewContainer()
apiV1Ws := new(restful.WebService)
apiV1Ws.Filter(wsLogger)
apiV1Ws.Path("/api/v1").
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)
wsContainer.Add(apiV1Ws)
apiV1Ws.Route(
apiV1Ws.POST("/appdeployment").
To(apiHandler.handleDeploy).
Reads(AppDeploymentSpec{}).
Writes(AppDeploymentSpec{}))
apiV1Ws.Route(
apiV1Ws.POST("/appdeployment/validate/name").
To(apiHandler.handleNameValidity).
Reads(AppNameValiditySpec{}).
Writes(AppNameValidity{}))
apiV1Ws.Route(
apiV1Ws.POST("/appdeployment/validate/imagereference").
To(apiHandler.handleImageReferenceValidity).
Reads(ImageReferenceValiditySpec{}).
Writes(ImageReferenceValidity{}))
apiV1Ws.Route(
apiV1Ws.POST("/appdeployment/validate/protocol").
To(apiHandler.handleProtocolValidity).
Reads(ProtocolValiditySpec{}).
Writes(ProtocolValidity{}))
apiV1Ws.Route(
apiV1Ws.GET("/appdeployment/protocols").
To(apiHandler.handleGetAvailableProcotols).
Writes(Protocols{}))
apiV1Ws.Route(
apiV1Ws.POST("/appdeploymentfromfile").
To(apiHandler.handleDeployFromFile).
Reads(AppDeploymentFromFileSpec{}).
Writes(AppDeploymentFromFileResponse{}))
apiV1Ws.Route(
apiV1Ws.GET("/replicationcontroller").
To(apiHandler.handleGetReplicationControllerList).
Writes(ReplicationControllerList{}))
apiV1Ws.Route(
apiV1Ws.GET("/replicationcontroller/{namespace}").
To(apiHandler.handleGetReplicationControllerList).
Writes(ReplicationControllerList{}))
apiV1Ws.Route(
apiV1Ws.GET("/replicationcontroller/{namespace}/{replicationController}").
To(apiHandler.handleGetReplicationControllerDetail).
Writes(ReplicationControllerDetail{}))
apiV1Ws.Route(
apiV1Ws.POST("/replicationcontroller/{namespace}/{replicationController}/update/pod").
To(apiHandler.handleUpdateReplicasCount).
Reads(ReplicationControllerSpec{}))
apiV1Ws.Route(
apiV1Ws.DELETE("/replicationcontroller/{namespace}/{replicationController}").
To(apiHandler.handleDeleteReplicationController))
apiV1Ws.Route(
apiV1Ws.GET("/replicationcontroller/pod/{namespace}/{replicationController}").
To(apiHandler.handleGetReplicationControllerPods).
Writes(ReplicationControllerPods{}))
apiV1Ws.Route(
apiV1Ws.GET("/workload").
To(apiHandler.handleGetWorkloads).
Writes(workload.Workloads{}))
apiV1Ws.Route(
apiV1Ws.GET("/workload/{namespace}").
To(apiHandler.handleGetWorkloads).
Writes(workload.Workloads{}))
apiV1Ws.Route(
apiV1Ws.GET("/replicaset").
To(apiHandler.handleGetReplicaSets).
Writes(replicaset.ReplicaSetList{}))
apiV1Ws.Route(
apiV1Ws.GET("/replicaset/{namespace}").
To(apiHandler.handleGetReplicaSets).
Writes(replicaset.ReplicaSetList{}))
apiV1Ws.Route(
apiV1Ws.GET("/replicaset/{namespace}/{replicaSet}").
To(apiHandler.handleGetReplicaSetDetail).
Writes(replicaset.ReplicaSetDetail{}))
apiV1Ws.Route(
apiV1Ws.GET("/pod").
To(apiHandler.handleGetPods).
Writes(pod.PodList{}))
apiV1Ws.Route(
apiV1Ws.GET("/pod/{namespace}").
To(apiHandler.handleGetPods).
//.........這裏部分代碼省略.........
示例4: CreateHttpApiHandler
// Creates a new HTTP handler that handles all requests to the API of the backend.
func CreateHttpApiHandler(client *client.Client) http.Handler {
apiHandler := ApiHandler{client}
wsContainer := restful.NewContainer()
deployWs := new(restful.WebService)
deployWs.Path("/api/appdeployments").
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)
deployWs.Route(
deployWs.POST("").
To(apiHandler.handleDeploy).
Reads(AppDeploymentSpec{}).
Writes(AppDeploymentSpec{}))
deployWs.Route(
deployWs.POST("/validate/name").
To(apiHandler.handleNameValidity).
Reads(AppNameValiditySpec{}).
Writes(AppNameValidity{}))
wsContainer.Add(deployWs)
replicaSetWs := new(restful.WebService)
replicaSetWs.Path("/api/replicasets").
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)
replicaSetWs.Route(
replicaSetWs.GET("").
To(apiHandler.handleGetReplicaSetList).
Writes(ReplicaSetList{}))
replicaSetWs.Route(
replicaSetWs.GET("/{namespace}/{replicaSet}").
To(apiHandler.handleGetReplicaSetDetail).
Writes(ReplicaSetDetail{}))
replicaSetWs.Route(
replicaSetWs.POST("/{namespace}/{replicaSet}/update/pods").
To(apiHandler.handleUpdateReplicasCount).
Reads(ReplicaSetSpec{}))
replicaSetWs.Route(
replicaSetWs.DELETE("/{namespace}/{replicaSet}").
To(apiHandler.handleDeleteReplicaSet))
replicaSetWs.Route(
replicaSetWs.GET("/pods/{namespace}/{replicaSet}").
To(apiHandler.handleGetReplicaSetPods).
Writes(ReplicaSetPods{}))
wsContainer.Add(replicaSetWs)
namespacesWs := new(restful.WebService)
namespacesWs.Path("/api/namespaces").
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)
namespacesWs.Route(
namespacesWs.POST("").
To(apiHandler.handleCreateNamespace).
Reads(NamespaceSpec{}).
Writes(NamespaceSpec{}))
namespacesWs.Route(
namespacesWs.GET("").
To(apiHandler.handleGetNamespaces).
Writes(NamespaceList{}))
wsContainer.Add(namespacesWs)
logsWs := new(restful.WebService)
logsWs.Path("/api/logs").
Produces(restful.MIME_JSON)
logsWs.Route(
logsWs.GET("/{namespace}/{podId}/{container}").
To(apiHandler.handleLogs).
Writes(Logs{}))
wsContainer.Add(logsWs)
eventsWs := new(restful.WebService)
eventsWs.Path("/api/events").
Produces(restful.MIME_JSON)
eventsWs.Route(
eventsWs.GET("/{namespace}/{replicaSet}").
To(apiHandler.handleEvents).
Writes(Events{}))
wsContainer.Add(eventsWs)
return wsContainer
}