This repository was archived by the owner on Aug 30, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +20
-10
lines changed
Expand file tree Collapse file tree 4 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -40,12 +40,9 @@ func processEntity(ent *models.Entity) {
4040 cancel ()
4141 }()
4242
43- var tracker trackers.Tracker
44- switch ent .Options .UseChrome {
45- case true :
43+ var tracker trackers.Tracker = trackers .SimpleTracker
44+ if ent .Options .UseChrome != nil && * ent .Options .UseChrome {
4645 tracker = trackers .ChromeTracker
47- default :
48- tracker = trackers .SimpleTracker
4946 }
5047
5148 content , ok := tracker (& ent .URL , & ent .XPATH )
Original file line number Diff line number Diff line change @@ -29,14 +29,14 @@ func Create(c echo.Context) error {
2929 ok bool
3030 )
3131
32- if ! req .Options .UseChrome {
32+ if req . Options . UseChrome == nil || ! * req .Options .UseChrome {
3333 content , ok = trackers .SimpleTracker (& req .URL , & req .XPATH )
3434 }
3535 if ! ok {
36- req .Options .UseChrome = true
36+ * req .Options .UseChrome = true
3737 log .Println ("INFO: Resorting to Chrome" )
3838 }
39- if req .Options .UseChrome {
39+ if req .Options .UseChrome != nil && * req . Options . UseChrome {
4040 if content , ok = trackers .ChromeTracker (& req .URL , & req .XPATH ); ! ok {
4141 return c .String (http .StatusBadRequest , content )
4242 }
Original file line number Diff line number Diff line change @@ -41,10 +41,20 @@ func Update(c echo.Context) error {
4141 if req .Options .Threshold != 0 {
4242 entity .Options .Threshold = req .Options .Threshold
4343 }
44- if req .Options .UseChrome {
44+ if req .Options .UseChrome != nil {
4545 entity .Options .UseChrome = req .Options .UseChrome
4646 }
4747
48+ if req .Name != "" {
49+ entity .Name = req .Name
50+ }
51+ if req .URL != "" {
52+ entity .URL = req .URL
53+ }
54+ if req .XPATH != "" {
55+ entity .XPATH = req .XPATH
56+ }
57+
4858 // update entity
4959 ctx1 , cancel1 := context .WithTimeout (context .Background (), gutils .CancelWaitTime )
5060 defer cancel1 ()
Original file line number Diff line number Diff line change 1010 AlertType string `json:"alertType"`
1111 Threshold float32 `json:"threshold"`
1212 MaxRecords int16 `json:"maxRecords"`
13- UseChrome bool `json:"useChrome"`
13+ UseChrome * bool `json:"useChrome"`
1414 }
1515
1616 // CreateRequest defines the contract to add an entry
2424
2525 // UpdateRequest defines the contract to update an entry
2626 UpdateRequest struct {
27+ URL string `json:"url"`
28+ XPATH string `json:"xpath"`
29+ Name string `json:"name"`
2730 Key * datastore.Key `json:"key"`
2831 Options * Options `json:"options"`
2932 }
You can’t perform that action at this time.
0 commit comments