mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-05-05 12:22:35 +02:00
Add stream search, offset & limit, improved bans
This commit is contained in:
parent
72f11a2b15
commit
963e392cea
14 changed files with 298 additions and 65 deletions
33
service/api/helpers/get-limits.go
Normal file
33
service/api/helpers/get-limits.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package helpers
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
const (
|
||||
DEFAULT_LIMIT = 10 // todo: move to config
|
||||
DEFAULT_OFFSET = 0
|
||||
)
|
||||
|
||||
func GetLimits(query url.Values) (int, int, error) {
|
||||
|
||||
limit := DEFAULT_LIMIT
|
||||
start_index := DEFAULT_OFFSET
|
||||
|
||||
var err error
|
||||
|
||||
if query.Get("limit") != "" {
|
||||
limit, err = strconv.Atoi(query.Get("limit"))
|
||||
}
|
||||
|
||||
if query.Get("start_index") != "" {
|
||||
start_index, err = strconv.Atoi(query.Get("start_index"))
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
return start_index, limit, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue