1 Star 0 Fork 0

付宇飞 / restful-api-demo

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
host.go 710 Bytes
Copy Edit Raw Blame History
付宇飞 authored 2022-07-16 18:15 . 添加Host HTTP接口
package http
import (
"gitee.com/fuyufei889/restful-api-demo/apps/host"
"github.com/gin-gonic/gin"
"github.com/infraboard/mcube/http/response"
)
// 用于暴露Host Service接口
func (h *Handler) createHost(c *gin.Context) {
// 解析用户传递过来的参数
ins := host.NewHost()
// 从用户传递的body里面把数据读到ins实例里面去
if err := c.Bind(ins); err != nil {
response.Failed(c.Writer, err)
return
}
// 内部接口服务调用
// c.Request.Context() http Context
// host实例
ins, err := h.svc.CreateHost(c.Request.Context(), ins)
// 出错情况
if err != nil {
response.Failed(c.Writer, err)
return
}
// 成功情况
response.Success(c.Writer, ins)
}
Go
1
https://gitee.com/fuyufei889/restful-api-demo.git
git@gitee.com:fuyufei889/restful-api-demo.git
fuyufei889
restful-api-demo
restful-api-demo
9a034922694f

Search