forked from JointCloud/pcm-coordinator
38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package cloud
|
|
|
|
import (
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
|
"io"
|
|
"k8s.io/apimachinery/pkg/util/json"
|
|
"net/http"
|
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
|
container "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
|
|
)
|
|
|
|
func ContainerCreateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
var req container.CreateParam
|
|
body, err := io.ReadAll(r.Body)
|
|
if err != nil {
|
|
result.ParamErrorResult(r, w, err)
|
|
return
|
|
}
|
|
|
|
if err = json.Unmarshal(body, &req); err != nil {
|
|
result.ParamErrorResult(r, w, err)
|
|
return
|
|
}
|
|
// 获取用户信息
|
|
userStr := r.Header.Get("User")
|
|
user := &models.JccUserInfo{}
|
|
json.Unmarshal([]byte(userStr), user)
|
|
req.UserId = user.Id
|
|
l := cloud.NewContainerCreateLogic(r.Context(), svcCtx)
|
|
resp, err := l.ContainerCreate(&req)
|
|
result.HttpResult(r, w, resp, err)
|
|
}
|
|
}
|