mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
7f636aef4f
- Introduce kolide.ListOptions to store pagination params (in the future it can also store ordering/filtering params) - Refactor service/datastore methods to take kolide.ListOptions - Implement pagination
32 lines
690 B
Go
32 lines
690 B
Go
package service
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
func decodeGetHostRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
id, err := idFromRequest(r, "id")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return getHostRequest{ID: id}, nil
|
|
}
|
|
|
|
func decodeDeleteHostRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
id, err := idFromRequest(r, "id")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return deleteHostRequest{ID: id}, nil
|
|
}
|
|
|
|
func decodeListHostsRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
opt, err := listOptionsFromRequest(r)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return listHostsRequest{ListOptions: opt}, nil
|
|
}
|