37 Star 396 Fork 72

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gke_subnetworks_endpoint.go 988 Bytes
一键复制 编辑 原始数据 按行查看 历史
Fyery 提交于 2019-02-12 16:04 . refactor the code duplication
package capabilities
import (
"fmt"
"net/http"
)
// NewGKESubnetworksHandler creates a new GKESubnetworksHandler
func NewGKESubnetworksHandler() *GKESubnetworksHandler {
return &GKESubnetworksHandler{}
}
// GKESubnetworksHandler lists available networks in GKE
type GKESubnetworksHandler struct {
}
type subnetworkCapabilitiesRequestBody struct {
capabilitiesRequestBody
Region string `json:"region"`
}
func (g *GKESubnetworksHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request) {
body := preCheck(writer, req)
if body == nil {
return
}
if body.Region == "" {
writer.WriteHeader(http.StatusBadRequest)
handleErr(writer, fmt.Errorf("invalid region"))
return
}
client, err := getComputeServiceClient(req.Context(), body.Credentials)
if err != nil {
writer.WriteHeader(http.StatusInternalServerError)
handleErr(writer, err)
return
}
result, err := client.Subnetworks.List(body.ProjectID, body.Region).Do()
postCheck(writer, result, err)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.2-rc5

搜索帮助

Cb406eda 1850385 E526c682 1850385