mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
feat: add uixt action handler
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0+2411072017
|
v5.0.0+2411072041
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ func NewServer(port int) error {
|
|||||||
apiV1PlatformSerial.POST("/stub/login", handleDeviceContext(), loginHandler)
|
apiV1PlatformSerial.POST("/stub/login", handleDeviceContext(), loginHandler)
|
||||||
apiV1PlatformSerial.POST("/stub/logout", handleDeviceContext(), logoutHandler)
|
apiV1PlatformSerial.POST("/stub/logout", handleDeviceContext(), logoutHandler)
|
||||||
|
|
||||||
|
// run uixt actions
|
||||||
|
apiV1PlatformSerial.POST("/uixt/action", handleDeviceContext(), uixtActionHandler)
|
||||||
|
|
||||||
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 {
|
||||||
log.Err(err).Msg("failed to start http server")
|
log.Err(err).Msg("failed to start http server")
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/code"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func uixtActionHandler(c *gin.Context) {
|
||||||
|
dExt, err := getContextDriver(c)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var req uixt.MobileAction
|
||||||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
|
handlerValidateRequestFailedContext(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = dExt.DoAction(req); err != nil {
|
||||||
|
log.Err(err).Interface("action", req).
|
||||||
|
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