File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
- "log "
4
+ "errors "
5
5
"net/http"
6
6
7
7
"github.com/gin-gonic/gin"
@@ -17,25 +17,31 @@ func killBrowserHandler(c *gin.Context) {
17
17
18
18
c .BindJSON (& data )
19
19
20
- command , err := findBrowser (data .Process )
20
+ if data .Process != "chrome" && data .Process != "chrom" {
21
+ c .JSON (http .StatusBadRequest , errors .New ("You can't kill the process" + data .Process ))
22
+ return
23
+ }
21
24
22
- log . Println ( command )
25
+ command , err := findBrowser ( data . Process )
23
26
24
27
if err != nil {
25
28
c .JSON (http .StatusInternalServerError , err .Error ())
29
+ return
26
30
}
27
31
28
32
if data .Action == "kill" || data .Action == "restart" {
29
33
_ , err := killBrowser (data .Process )
30
34
if err != nil {
31
35
c .JSON (http .StatusInternalServerError , err .Error ())
36
+ return
32
37
}
33
38
}
34
39
35
40
if data .Action == "restart" {
36
41
_ , err := startBrowser (command , data .URL )
37
42
if err != nil {
38
43
c .JSON (http .StatusInternalServerError , err .Error ())
44
+ return
39
45
}
40
46
}
41
47
You can’t perform that action at this time.
0 commit comments