mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-31 13:29:35 +08:00
fix: merge
This commit is contained in:
@@ -5,8 +5,8 @@ import (
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt"
|
||||
)
|
||||
|
||||
func foregroundAppHandler(c *gin.Context) {
|
||||
driver, err := GetDriver(c)
|
||||
func (r *Router) foregroundAppHandler(c *gin.Context) {
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -18,7 +18,7 @@ func foregroundAppHandler(c *gin.Context) {
|
||||
RenderSuccess(c, appInfo)
|
||||
}
|
||||
|
||||
func appInfoHandler(c *gin.Context) {
|
||||
func (r *Router) appInfoHandler(c *gin.Context) {
|
||||
var appInfoReq AppInfoRequest
|
||||
if err := c.ShouldBindQuery(&appInfoReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
@@ -47,18 +47,18 @@ func appInfoHandler(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func clearAppHandler(c *gin.Context) {
|
||||
func (r *Router) clearAppHandler(c *gin.Context) {
|
||||
var appClearReq AppClearRequest
|
||||
if err := c.ShouldBindJSON(&appClearReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = driver.IDriver.(*uixt.ADBDriver).AppClear(appClearReq.PackageName)
|
||||
err = driver.GetIDriver().(*uixt.ADBDriver).AppClear(appClearReq.PackageName)
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
return
|
||||
@@ -66,13 +66,13 @@ func clearAppHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func launchAppHandler(c *gin.Context) {
|
||||
func (r *Router) launchAppHandler(c *gin.Context) {
|
||||
var appLaunchReq AppLaunchRequest
|
||||
if err := c.ShouldBindJSON(&appLaunchReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -84,13 +84,13 @@ func launchAppHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func terminalAppHandler(c *gin.Context) {
|
||||
func (r *Router) terminalAppHandler(c *gin.Context) {
|
||||
var appTerminalReq AppTerminalRequest
|
||||
if err := c.ShouldBindJSON(&appTerminalReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -102,13 +102,13 @@ func terminalAppHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func uninstallAppHandler(c *gin.Context) {
|
||||
func (r *Router) uninstallAppHandler(c *gin.Context) {
|
||||
var appUninstallReq AppUninstallRequest
|
||||
if err := c.ShouldBindJSON(&appUninstallReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
|
||||
)
|
||||
|
||||
func GetDriver(c *gin.Context) (driverExt *uixt.XTDriver, err error) {
|
||||
func (p RouterBaseMethod) GetDriver(c *gin.Context) (driverExt uixt.IXTDriver, err error) {
|
||||
deviceObj, exists := c.Get("device")
|
||||
var device uixt.IDevice
|
||||
var driver uixt.IDriver
|
||||
@@ -54,7 +54,6 @@ func GetDevice(c *gin.Context) (device uixt.IDevice, err error) {
|
||||
RenderErrorInitDriver(c, err)
|
||||
return
|
||||
}
|
||||
_ = device.Setup()
|
||||
case "ios":
|
||||
device, err = uixt.NewIOSDevice(
|
||||
option.WithUDID(serial),
|
||||
@@ -76,6 +75,10 @@ func GetDevice(c *gin.Context) (device uixt.IDevice, err error) {
|
||||
err = fmt.Errorf("[%s]: invalid platform", c.HandlerName())
|
||||
return
|
||||
}
|
||||
err = device.Setup()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("setup device failed")
|
||||
}
|
||||
c.Set("device", device)
|
||||
return device, nil
|
||||
}
|
||||
|
||||
@@ -7,14 +7,13 @@ import (
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/danielpaulus/go-ios/ios"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/httprunner/httprunner/v5/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v5/pkg/gadb"
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt"
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
func listDeviceHandler(c *gin.Context) {
|
||||
func (r *Router) listDeviceHandler(c *gin.Context) {
|
||||
var deviceList []interface{}
|
||||
client, err := gadb.NewClient()
|
||||
if err == nil {
|
||||
@@ -119,16 +118,17 @@ func deleteBrowserHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
func pushImageHandler(c *gin.Context) {
|
||||
func (r *Router) pushImageHandler(c *gin.Context) {
|
||||
var pushMediaReq PushMediaRequest
|
||||
if err := c.ShouldBindJSON(&pushMediaReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
imagePath, err := builtin.DownloadFileByUrl(pushMediaReq.ImageUrl)
|
||||
imagePath, err := uixt.DownloadFileByUrl(pushMediaReq.ImageUrl)
|
||||
if path.Ext(imagePath) == "" {
|
||||
err = os.Rename(imagePath, imagePath+".png")
|
||||
if err != nil {
|
||||
@@ -152,8 +152,8 @@ func pushImageHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func clearImageHandler(c *gin.Context) {
|
||||
driver, err := GetDriver(c)
|
||||
func (r *Router) clearImageHandler(c *gin.Context) {
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -165,6 +165,6 @@ func clearImageHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func videoHandler(c *gin.Context) {
|
||||
func (r *Router) videoHandler(c *gin.Context) {
|
||||
RenderSuccess(c, "")
|
||||
}
|
||||
|
||||
@@ -2,26 +2,26 @@ package server_ext
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt/driver_ext"
|
||||
"os"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/httprunner/httprunner/v5/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt"
|
||||
"github.com/httprunner/httprunner/v5/server"
|
||||
)
|
||||
|
||||
func installAppHandler(c *gin.Context) {
|
||||
func (r *RouterExt) installAppHandler(c *gin.Context) {
|
||||
var appInstallReq AppInstallRequest
|
||||
if err := c.ShouldBindJSON(&appInstallReq); err != nil {
|
||||
server.RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = driver.InstallByUrl(appInstallReq.AppUrl)
|
||||
err = driver.(*driver_ext.XTDriver).InstallByUrl(appInstallReq.AppUrl)
|
||||
if err != nil {
|
||||
server.RenderError(c, err)
|
||||
return
|
||||
@@ -32,7 +32,7 @@ func installAppHandler(c *gin.Context) {
|
||||
server.RenderSuccess(c, true)
|
||||
return
|
||||
}
|
||||
localMappingPath, err := builtin.DownloadFileByUrl(appInstallReq.MappingUrl)
|
||||
localMappingPath, err := uixt.DownloadFileByUrl(appInstallReq.MappingUrl)
|
||||
if err != nil {
|
||||
server.RenderError(c, err)
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func installAppHandler(c *gin.Context) {
|
||||
server.RenderError(c, err)
|
||||
return
|
||||
}
|
||||
localResourceMappingPath, err := builtin.DownloadFileByUrl(
|
||||
localResourceMappingPath, err := uixt.DownloadFileByUrl(
|
||||
appInstallReq.ResourceMappingUrl)
|
||||
if err != nil {
|
||||
server.RenderError(c, err)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/httprunner/httprunner/v5/server"
|
||||
)
|
||||
|
||||
func GetDriver(c *gin.Context) (driverExt *driver_ext.XTDriver, err error) {
|
||||
func (p RouterBaseMethodExt) GetDriver(c *gin.Context) (driverExt uixt.IXTDriver, err error) {
|
||||
platform := c.Param("platform")
|
||||
serial := c.Param("serial")
|
||||
deviceObj, exists := c.Get("device")
|
||||
|
||||
@@ -8,18 +8,18 @@ import (
|
||||
"github.com/httprunner/httprunner/v5/server"
|
||||
)
|
||||
|
||||
func loginHandler(c *gin.Context) {
|
||||
func (r *RouterExt) loginHandler(c *gin.Context) {
|
||||
var loginReq LoginRequest
|
||||
if err := c.ShouldBindJSON(&loginReq); err != nil {
|
||||
server.RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
info, err := driver.IDriver.(driver_ext.IStubDriver).
|
||||
info, err := driver.GetIDriver().(driver_ext.IStubDriver).
|
||||
LoginNoneUI(loginReq.PackageName, loginReq.PhoneNumber,
|
||||
loginReq.Captcha, loginReq.Password)
|
||||
if err != nil {
|
||||
@@ -29,18 +29,18 @@ func loginHandler(c *gin.Context) {
|
||||
server.RenderSuccess(c, info)
|
||||
}
|
||||
|
||||
func logoutHandler(c *gin.Context) {
|
||||
func (r *RouterExt) logoutHandler(c *gin.Context) {
|
||||
var logoutReq LogoutRequest
|
||||
if err := c.ShouldBindJSON(&logoutReq); err != nil {
|
||||
server.RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = driver.IDriver.(driver_ext.IStubDriver).
|
||||
err = driver.GetIDriver().(driver_ext.IStubDriver).
|
||||
LogoutNoneUI(logoutReq.PackageName)
|
||||
if err != nil {
|
||||
server.RenderError(c, err)
|
||||
@@ -49,8 +49,8 @@ func logoutHandler(c *gin.Context) {
|
||||
server.RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func sourceHandler(c *gin.Context) {
|
||||
driver, err := GetDriver(c)
|
||||
func (r *RouterExt) sourceHandler(c *gin.Context) {
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,16 +1,35 @@
|
||||
package server_ext
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/httprunner/httprunner/v5/server"
|
||||
)
|
||||
|
||||
func NewExtRouter() *server.Router {
|
||||
router := server.NewRouter()
|
||||
apiV1PlatformSerial := router.Group("/api/v1").Group("/:platform").Group("/:serial")
|
||||
type RouterExt struct {
|
||||
*server.Router
|
||||
}
|
||||
|
||||
apiV1PlatformSerial.GET("/stub/source", sourceHandler)
|
||||
apiV1PlatformSerial.POST("/stub/login", loginHandler)
|
||||
apiV1PlatformSerial.POST("/stub/logout", logoutHandler)
|
||||
apiV1PlatformSerial.POST("/app/install", installAppHandler)
|
||||
type RouterBaseMethodExt struct {
|
||||
server.RouterBaseMethod
|
||||
}
|
||||
|
||||
func NewExtRouter() *RouterExt {
|
||||
router := &RouterExt{
|
||||
Router: &server.Router{
|
||||
Engine: gin.Default(),
|
||||
IRouterBaseMethod: &RouterBaseMethodExt{},
|
||||
},
|
||||
}
|
||||
router.Init()
|
||||
return router
|
||||
}
|
||||
|
||||
func (r *RouterExt) Init() {
|
||||
r.Router.Init()
|
||||
apiV1PlatformSerial := r.Group("/api/v1").Group("/:platform").Group("/:serial")
|
||||
|
||||
apiV1PlatformSerial.GET("/stub/source", r.sourceHandler)
|
||||
apiV1PlatformSerial.POST("/stub/login", r.loginHandler)
|
||||
apiV1PlatformSerial.POST("/stub/logout", r.logoutHandler)
|
||||
apiV1PlatformSerial.POST("/app/install", r.installAppHandler)
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt"
|
||||
)
|
||||
|
||||
func unlockHandler(c *gin.Context) {
|
||||
driver, err := GetDriver(c)
|
||||
func (r *Router) unlockHandler(c *gin.Context) {
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -19,8 +19,8 @@ func unlockHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func homeHandler(c *gin.Context) {
|
||||
driver, err := GetDriver(c)
|
||||
func (r *Router) homeHandler(c *gin.Context) {
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -32,7 +32,7 @@ func homeHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func backspaceHandler(c *gin.Context) {
|
||||
func (r *Router) backspaceHandler(c *gin.Context) {
|
||||
var deleteReq DeleteRequest
|
||||
if err := c.ShouldBindJSON(&deleteReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
@@ -41,7 +41,7 @@ func backspaceHandler(c *gin.Context) {
|
||||
if deleteReq.Count == 0 {
|
||||
deleteReq.Count = 20
|
||||
}
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -53,18 +53,18 @@ func backspaceHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func keycodeHandler(c *gin.Context) {
|
||||
func (r *Router) keycodeHandler(c *gin.Context) {
|
||||
var keycodeReq KeycodeRequest
|
||||
if err := c.ShouldBindJSON(&keycodeReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// TODO FIXME
|
||||
err = driver.IDriver.(*uixt.ADBDriver).
|
||||
err = driver.GetIDriver().(*uixt.ADBDriver).
|
||||
PressKeyCode(uixt.KeyCode(keycodeReq.Keycode), uixt.KMEmpty)
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
|
||||
@@ -11,17 +11,27 @@ import (
|
||||
)
|
||||
|
||||
func NewRouter() *Router {
|
||||
router := &Router{}
|
||||
router := &Router{
|
||||
Engine: gin.Default(),
|
||||
IRouterBaseMethod: &RouterBaseMethod{},
|
||||
}
|
||||
router.Init()
|
||||
return router
|
||||
}
|
||||
|
||||
type Router struct {
|
||||
*gin.Engine
|
||||
IRouterBaseMethod
|
||||
}
|
||||
|
||||
type RouterBaseMethod struct {
|
||||
}
|
||||
|
||||
type IRouterBaseMethod interface {
|
||||
GetDriver(c *gin.Context) (driver uixt.IXTDriver, err error)
|
||||
}
|
||||
|
||||
func (r *Router) Init() {
|
||||
r.Engine = gin.Default()
|
||||
r.Engine.Use(teardown())
|
||||
r.Engine.GET("/ping", pingHandler)
|
||||
r.Engine.GET("/", pingHandler)
|
||||
@@ -42,18 +52,18 @@ func (r *Router) Init() {
|
||||
apiV1PlatformSerial.POST("/ui/scroll", scrollHandler)
|
||||
|
||||
// Key operations
|
||||
apiV1PlatformSerial.POST("/key/unlock", unlockHandler)
|
||||
apiV1PlatformSerial.POST("/key/home", homeHandler)
|
||||
apiV1PlatformSerial.POST("/key/backspace", backspaceHandler)
|
||||
apiV1PlatformSerial.POST("/key", keycodeHandler)
|
||||
apiV1PlatformSerial.POST("/key/unlock", r.unlockHandler)
|
||||
apiV1PlatformSerial.POST("/key/home", r.homeHandler)
|
||||
apiV1PlatformSerial.POST("/key/backspace", r.backspaceHandler)
|
||||
apiV1PlatformSerial.POST("/key", r.keycodeHandler)
|
||||
|
||||
// APP operations
|
||||
apiV1PlatformSerial.GET("/app/foreground", foregroundAppHandler)
|
||||
apiV1PlatformSerial.GET("/app/appInfo", appInfoHandler)
|
||||
apiV1PlatformSerial.POST("/app/clear", clearAppHandler)
|
||||
apiV1PlatformSerial.POST("/app/launch", launchAppHandler)
|
||||
apiV1PlatformSerial.POST("/app/terminal", terminalAppHandler)
|
||||
apiV1PlatformSerial.POST("/app/uninstall", uninstallAppHandler)
|
||||
apiV1PlatformSerial.GET("/app/foreground", r.foregroundAppHandler)
|
||||
apiV1PlatformSerial.GET("/app/appInfo", r.appInfoHandler)
|
||||
apiV1PlatformSerial.POST("/app/clear", r.clearAppHandler)
|
||||
apiV1PlatformSerial.POST("/app/launch", r.launchAppHandler)
|
||||
apiV1PlatformSerial.POST("/app/terminal", r.terminalAppHandler)
|
||||
apiV1PlatformSerial.POST("/app/uninstall", r.uninstallAppHandler)
|
||||
|
||||
// Device operations
|
||||
apiV1PlatformSerial.GET("/screenshot", screenshotHandler)
|
||||
@@ -64,8 +74,8 @@ func (r *Router) Init() {
|
||||
apiV1PlatformSerial.GET("/adb/source", adbSourceHandler)
|
||||
|
||||
// uixt operations
|
||||
apiV1PlatformSerial.POST("/uixt/action", uixtActionHandler)
|
||||
apiV1PlatformSerial.POST("/uixt/actions", uixtActionsHandler)
|
||||
apiV1PlatformSerial.POST("/uixt/action", r.uixtActionHandler)
|
||||
apiV1PlatformSerial.POST("/uixt/actions", r.uixtActionsHandler)
|
||||
}
|
||||
|
||||
func (r *Router) Run(port int) error {
|
||||
@@ -77,7 +87,7 @@ func (r *Router) Run(port int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func pingHandler(c *gin.Context) {
|
||||
func (r *Router) pingHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
|
||||
)
|
||||
|
||||
func screenshotHandler(c *gin.Context) {
|
||||
driver, err := GetDriver(c)
|
||||
func (r *Router) screenshotHandler(c *gin.Context) {
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -23,8 +23,8 @@ func screenshotHandler(c *gin.Context) {
|
||||
RenderSuccess(c, base64.StdEncoding.EncodeToString(raw.Bytes()))
|
||||
}
|
||||
|
||||
func screenResultHandler(c *gin.Context) {
|
||||
dExt, err := GetDriver(c)
|
||||
func (r *Router) screenResultHandler(c *gin.Context) {
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func screenResultHandler(c *gin.Context) {
|
||||
actionOptions = screenReq.Options.Options()
|
||||
}
|
||||
|
||||
screenResult, err := dExt.GetScreenResult(actionOptions...)
|
||||
screenResult, err := driver.GetScreenResult(actionOptions...)
|
||||
if err != nil {
|
||||
log.Err(err).Msg("get screen result failed")
|
||||
RenderError(c, err)
|
||||
@@ -49,8 +49,8 @@ func screenResultHandler(c *gin.Context) {
|
||||
RenderSuccess(c, screenResult)
|
||||
}
|
||||
|
||||
func adbSourceHandler(c *gin.Context) {
|
||||
dExt, err := GetDriver(c)
|
||||
func (r *Router) adbSourceHandler(c *gin.Context) {
|
||||
dExt, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
16
server/ui.go
16
server/ui.go
@@ -6,13 +6,13 @@ import (
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
|
||||
)
|
||||
|
||||
func tapHandler(c *gin.Context) {
|
||||
func (r *Router) tapHandler(c *gin.Context) {
|
||||
var tapReq TapRequest
|
||||
if err := c.ShouldBindJSON(&tapReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -93,14 +93,14 @@ func scrollHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func doubleTapHandler(c *gin.Context) {
|
||||
func (r *Router) doubleTapHandler(c *gin.Context) {
|
||||
var tapReq TapRequest
|
||||
if err := c.ShouldBindJSON(&tapReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -119,7 +119,7 @@ func doubleTapHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func dragHandler(c *gin.Context) {
|
||||
func (r *Router) dragHandler(c *gin.Context) {
|
||||
var dragReq DragRequest
|
||||
if err := c.ShouldBindJSON(&dragReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
@@ -128,7 +128,7 @@ func dragHandler(c *gin.Context) {
|
||||
if dragReq.Duration == 0 {
|
||||
dragReq.Duration = 1
|
||||
}
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -143,13 +143,13 @@ func dragHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func inputHandler(c *gin.Context) {
|
||||
func (r *Router) inputHandler(c *gin.Context) {
|
||||
var inputReq InputRequest
|
||||
if err := c.ShouldBindJSON(&inputReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
)
|
||||
|
||||
// exec a single uixt action
|
||||
func uixtActionHandler(c *gin.Context) {
|
||||
dExt, err := GetDriver(c)
|
||||
func (r *Router) uixtActionHandler(c *gin.Context) {
|
||||
dExt, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -29,8 +29,8 @@ func uixtActionHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
// exec multiple uixt actions
|
||||
func uixtActionsHandler(c *gin.Context) {
|
||||
dExt, err := GetDriver(c)
|
||||
func (r *Router) uixtActionsHandler(c *gin.Context) {
|
||||
dExt, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user