1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Add more filters for API call /entries

New filters:

- before (unix timestamp)
- before_entry_id
- after
- after_entry_id
- starred (boolean)
This commit is contained in:
Frédéric Guillot 2018-06-09 19:13:41 -07:00
parent c5373ff2bf
commit 36dab8b518
7 changed files with 99 additions and 17 deletions

View file

@ -24,11 +24,15 @@ func Cookie(r *http.Request, name string) string {
return cookie.Value
}
// FormIntValue returns a form value as integer.
func FormIntValue(r *http.Request, param string) int64 {
// FormInt64Value returns a form value as integer.
func FormInt64Value(r *http.Request, param string) int64 {
value := r.FormValue(param)
integer, _ := strconv.Atoi(value)
return int64(integer)
integer, err := strconv.ParseInt(value, 10, 64)
if err != nil {
return 0
}
return integer
}
// IntParam returns an URL route parameter as integer.
@ -67,12 +71,17 @@ func QueryParam(r *http.Request, param, defaultValue string) string {
// QueryIntParam returns a querystring parameter as integer.
func QueryIntParam(r *http.Request, param string, defaultValue int) int {
return int(QueryInt64Param(r, param, int64(defaultValue)))
}
// QueryInt64Param returns a querystring parameter as int64.
func QueryInt64Param(r *http.Request, param string, defaultValue int64) int64 {
value := r.URL.Query().Get(param)
if value == "" {
return defaultValue
}
val, err := strconv.Atoi(value)
val, err := strconv.ParseInt(value, 10, 64)
if err != nil {
return defaultValue
}