(ctx *gin.Context)
| 240 | } |
| 241 | |
| 242 | func StopInstanceHandler(ctx *gin.Context) { |
| 243 | var req ginmodel.SingleInstanceRequest |
| 244 | if err := ctx.Bind(&req); err != nil { |
| 245 | jsonResp := ginmodel.JsonResp{ |
| 246 | Code: -1, |
| 247 | Message: fmt.Sprintf("Invalid Request Data: %s", err.Error()), |
| 248 | } |
| 249 | ctx.JSON(http.StatusBadRequest, jsonResp) |
| 250 | return |
| 251 | } |
| 252 | |
| 253 | err := synchronizer.UpdateInstanceInfo(req.NodeIndex, req.InstanceID, func(i *model.Instance) error { |
| 254 | i.Start = false |
| 255 | return nil |
| 256 | }) |
| 257 | if err != nil { |
| 258 | jsonResp := ginmodel.JsonResp{ |
| 259 | Code: -1, |
| 260 | Message: fmt.Sprintf("Stop Instance Error: %s", err.Error()), |
| 261 | } |
| 262 | ctx.JSON(http.StatusInternalServerError, jsonResp) |
| 263 | return |
| 264 | } |
| 265 | jsonResp := ginmodel.JsonResp{ |
| 266 | Code: 0, |
| 267 | Message: "Success", |
| 268 | } |
| 269 | ctx.JSON(http.StatusOK, jsonResp) |
| 270 | } |
nothing calls this directly
no outgoing calls
no test coverage detected