From 806b7696ea9f2c595e5de8b25e2a0c9eee4e0f58 Mon Sep 17 00:00:00 2001 From: codeskyblue Date: Mon, 25 Mar 2019 16:54:58 +0800 Subject: [PATCH] DEL /uiautomator status 500->200, close #26 --- README.md | 10 ++++++++++ restapi.go => httprestapi.go | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) rename restapi.go => httprestapi.go (99%) diff --git a/README.md b/README.md index a912cab..d606d54 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,16 @@ Success # 停止 $ curl -X DELETE $DEVICE_URL/uiautomator Success + +# 再次停止 +$ curl -X DELETE $DEVICE_URL/uiautomator +Already stopped + +# 获取uiautomator状态 +$ curl $DEVICE/uiautomator +{ + "running": true +} ``` ## 启动应用 diff --git a/restapi.go b/httprestapi.go similarity index 99% rename from restapi.go rename to httprestapi.go index 446bc9f..42e7f55 100644 --- a/restapi.go +++ b/httprestapi.go @@ -346,7 +346,7 @@ func (server *Server) initHTTPServer() { if err == nil { io.WriteString(w, "Success") } else { - http.Error(w, err.Error(), 500) + io.WriteString(w, "Already stopped") } }).Methods("DELETE") @@ -355,7 +355,7 @@ func (server *Server) initHTTPServer() { renderJSON(w, map[string]interface{}{ "running": running, }) - }) + }).Methods("GET") m.HandleFunc("/raw/{filepath:.*}", func(w http.ResponseWriter, r *http.Request) { filepath := mux.Vars(r)["filepath"]