mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-02 22:39:42 +08:00
feat: exec multiple uixt actions
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0+2411072041
|
v5.0.0+2411072100
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ func NewServer(port int) error {
|
|||||||
|
|
||||||
// run uixt actions
|
// run uixt actions
|
||||||
apiV1PlatformSerial.POST("/uixt/action", handleDeviceContext(), uixtActionHandler)
|
apiV1PlatformSerial.POST("/uixt/action", handleDeviceContext(), uixtActionHandler)
|
||||||
|
apiV1PlatformSerial.POST("/uixt/actions", handleDeviceContext(), uixtActionsHandler)
|
||||||
|
|
||||||
err := router.Run(fmt.Sprintf("127.0.0.1:%d", port))
|
err := router.Run(fmt.Sprintf("127.0.0.1:%d", port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// exec a single uixt action
|
||||||
func uixtActionHandler(c *gin.Context) {
|
func uixtActionHandler(c *gin.Context) {
|
||||||
dExt, err := getContextDriver(c)
|
dExt, err := getContextDriver(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -36,3 +37,34 @@ func uixtActionHandler(c *gin.Context) {
|
|||||||
|
|
||||||
c.JSON(http.StatusOK, HttpResponse{Code: 0, Message: "success"})
|
c.JSON(http.StatusOK, HttpResponse{Code: 0, Message: "success"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// exec multiple uixt actions
|
||||||
|
func uixtActionsHandler(c *gin.Context) {
|
||||||
|
dExt, err := getContextDriver(c)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var actions []uixt.MobileAction
|
||||||
|
if err := c.ShouldBindJSON(&actions); err != nil {
|
||||||
|
handlerValidateRequestFailedContext(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, action := range actions {
|
||||||
|
if err = dExt.DoAction(action); err != nil {
|
||||||
|
log.Err(err).Interface("action", action).
|
||||||
|
Msg("exec uixt action failed")
|
||||||
|
c.JSON(http.StatusInternalServerError,
|
||||||
|
HttpResponse{
|
||||||
|
Code: code.GetErrorCode(err),
|
||||||
|
Message: err.Error(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
c.Abort()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, HttpResponse{Code: 0, Message: "success"})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user