mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 17:28:54 +00:00
38 lines
830 B
Go
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
|
|
}
|