fleet/server/service/transport_teams.go
2021-04-06 11:40:14 -07:00

38 lines
830 B
Go

package service
import (
"context"
"encoding/json"
"net/http"
)
func decodeCreateTeamRequest(ctx context.Context, r *http.Request) (interface{}, error) {
var req createTeamRequest
if err := json.NewDecoder(r.Body).Decode(&req.payload); err != nil {
return nil, err
}
return req, nil
}
func decodeModifyTeamRequest(ctx context.Context, r *http.Request) (interface{}, error) {
id, err := idFromRequest(r, "id")
if err != nil {
return nil, err
}
var resp modifyTeamRequest
err = json.NewDecoder(r.Body).Decode(&resp.payload)
if err != nil {
return nil, err
}
resp.ID = id
return resp, nil
}
func decodeListTeamsRequest(ctx context.Context, r *http.Request) (interface{}, error) {
opt, err := listOptionsFromRequest(r)
if err != nil {
return nil, err
}
return listTeamsRequest{ListOptions: opt}, nil
}