weldr: always return original offset and limit values
This commit is contained in:
parent
f0e2e3786f
commit
8cde1b6bd5
2 changed files with 8 additions and 8 deletions
14
weldr/api.go
14
weldr/api.go
|
|
@ -204,12 +204,12 @@ func (api *API) modulesListAllHandler(writer http.ResponseWriter, request *http.
|
|||
}
|
||||
|
||||
total := uint(len(api.packages))
|
||||
offset = min(offset, total)
|
||||
limit = min(limit, total-offset)
|
||||
start := min(offset, total)
|
||||
n := min(limit, total-start)
|
||||
|
||||
modules := make([]modulesListModule, limit)
|
||||
for i := uint(0); i < limit; i++ {
|
||||
modules[i] = modulesListModule{api.packages[offset+i].Name, "rpm"}
|
||||
modules := make([]modulesListModule, n)
|
||||
for i := uint(0); i < n; i++ {
|
||||
modules[i] = modulesListModule{api.packages[start+i].Name, "rpm"}
|
||||
}
|
||||
|
||||
json.NewEncoder(writer).Encode(modulesListReply{
|
||||
|
|
@ -256,8 +256,8 @@ func (api *API) modulesListHandler(writer http.ResponseWriter, request *http.Req
|
|||
|
||||
json.NewEncoder(writer).Encode(modulesListReply{
|
||||
Total: total,
|
||||
Offset: min(offset, total),
|
||||
Limit: min(limit, total-offset),
|
||||
Offset: offset,
|
||||
Limit: limit,
|
||||
Modules: modules,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
func parseOffsetAndLimit(query url.Values) (uint, uint, error) {
|
||||
var offset, limit uint64 = 0, 10
|
||||
var offset, limit uint64 = 0, 20
|
||||
var err error
|
||||
|
||||
if v := query.Get("offset"); v != "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue