@@ -68,6 +68,7 @@ func AllRecipeHandler(req *http.Request, client *http.Client) []Recipe {
68
68
skip := config .DefaultSkip
69
69
if len (req .URL .Query ()["top" ]) > 0 {
70
70
top , _ = strconv .Atoi (req .URL .Query ()["top" ][0 ])
71
+ // Avoid fetching negative ids to reduce traffic
71
72
if top < 0 {
72
73
top = 0
73
74
}
@@ -77,6 +78,7 @@ func AllRecipeHandler(req *http.Request, client *http.Client) []Recipe {
77
78
}
78
79
if len (req .URL .Query ()["skip" ]) > 0 {
79
80
skip , _ = strconv .Atoi (req .URL .Query ()["skip" ][0 ])
81
+ // Avoid fetching negative ids to reduce traffic
80
82
if skip < 0 {
81
83
skip = config .DefaultSkip
82
84
}
@@ -91,8 +93,8 @@ func AllRecipeHandler(req *http.Request, client *http.Client) []Recipe {
91
93
}
92
94
93
95
// Fetch recipes with given ids
96
+ // To reduce traffic, only those with valid and positive ids are fetched
94
97
func AggregatedRecipeHandler (req * http.Request , client * http.Client ) []Recipe {
95
- // ids := strings.Split(req.URL.Query()["ids"][0], ",")
96
98
ids := Filter (strings .Split (req .URL .Query ()["ids" ][0 ], "," ), func (s string ) bool {
97
99
val , _ := strconv .Atoi (s )
98
100
return val > 0
0 commit comments