37 Star 396 Fork 72

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
http_request_body.go 527 Bytes
一键复制 编辑 原始数据 按行查看 历史
Nathan Jenan 提交于 2018-06-18 10:15 . Adding aks version endpoint
package capabilities
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func extractRequestBody(writer http.ResponseWriter, req *http.Request, body interface{}) error {
raw, err := ioutil.ReadAll(req.Body)
if err != nil {
writer.WriteHeader(http.StatusBadRequest)
return fmt.Errorf("cannot read request body: " + err.Error())
}
err = json.Unmarshal(raw, &body)
if err != nil {
writer.WriteHeader(http.StatusBadRequest)
return fmt.Errorf("cannot parse request body: " + err.Error())
}
return nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.1.12-rc5

搜索帮助

Cb406eda 1850385 E526c682 1850385