mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-03 06:49:38 +08:00
feat: get screen result for hrp ui server
This commit is contained in:
@@ -30,7 +30,51 @@ func screenshotHandler(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, HttpResponse{Result: base64.StdEncoding.EncodeToString(raw.Bytes())})
|
||||
c.JSON(http.StatusOK,
|
||||
HttpResponse{
|
||||
Code: code.Success,
|
||||
Message: "success",
|
||||
Result: base64.StdEncoding.EncodeToString(raw.Bytes()),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func screenResultHandler(c *gin.Context) {
|
||||
dExt, err := getContextDriver(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var screenReq ScreenRequest
|
||||
if err := c.ShouldBindJSON(&screenReq); err != nil {
|
||||
handlerValidateRequestFailedContext(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
var actionOptions []uixt.ActionOption
|
||||
if screenReq.Options != nil {
|
||||
actionOptions = screenReq.Options.Options()
|
||||
}
|
||||
|
||||
screenResult, err := dExt.GetScreenResult(actionOptions...)
|
||||
if err != nil {
|
||||
log.Err(err).Msg("get screen result failed")
|
||||
c.JSON(http.StatusInternalServerError,
|
||||
HttpResponse{
|
||||
Code: code.GetErrorCode(err),
|
||||
Message: err.Error(),
|
||||
},
|
||||
)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK,
|
||||
HttpResponse{
|
||||
Code: code.Success,
|
||||
Message: "success",
|
||||
Result: screenResult,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func sourceHandler(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user