@@ -29,27 +29,30 @@ import (
29
29
// helpHandler returns the contents of `adb help` as plaintext.
30
30
func helpHandler (response http.ResponseWriter , request * http.Request ) {
31
31
adbRun := adb .NewRun ("help" )
32
- if err := proxyAdbRun (response , & adbRun ); err == nil {
33
- response .Header ().Set ("Content-Type" , "text/plain; charset=utf-8" )
34
- response .WriteHeader (http .StatusOK )
35
-
36
- response .Write (adbRun .StdOut )
32
+ if err := proxyAdbRun (response , & adbRun ); err != nil {
33
+ return
37
34
}
35
+
36
+ response .Header ().Set ("Content-Type" , "text/plain; charset=utf-8" )
37
+ response .WriteHeader (http .StatusOK )
38
+ response .Write (adbRun .StdOut )
38
39
}
39
40
40
41
// devicesHandler returns the contents of `adb devices -l` as JSON.
41
42
// TODO: Add example JSON here.
42
43
func devicesHandler (response http.ResponseWriter , request * http.Request ) {
43
44
adbRun := adb .NewRun ("devices" , "-l" )
44
- if err := proxyAdbRun (response , & adbRun ); err == nil {
45
- deviceList , err := adb .ParseDeviceList (adbRun .StdOut )
46
- if err != nil {
47
- // TODO: Make a 502 helper method
48
- return
49
- }
50
-
51
- writeResponseAsJSON (response , deviceList )
45
+ if err := proxyAdbRun (response , & adbRun ); err != nil {
46
+ return
52
47
}
48
+
49
+ deviceList , err := adb .ParseDeviceList (adbRun .StdOut )
50
+ if err != nil {
51
+ // TODO: Make a 502 helper method
52
+ return
53
+ }
54
+
55
+ writeResponseAsJSON (response , deviceList )
53
56
}
54
57
55
58
// proxyAdbRun executes the command stored in the provided adb.Run instance and handles
0 commit comments