fleet/server/service/transport_labels.go
Mike Arpaia 97de2bc5aa Label API Updates (#413)
close #403
close #404
close #412
2016-11-02 21:17:23 -04:00

45 lines
979 B
Go

package service
import (
"encoding/json"
"net/http"
"golang.org/x/net/context"
)
func decodeCreateLabelRequest(ctx context.Context, r *http.Request) (interface{}, error) {
var req createLabelRequest
if err := json.NewDecoder(r.Body).Decode(&req.payload); err != nil {
return nil, err
}
return req, nil
}
func decodeDeleteLabelRequest(ctx context.Context, r *http.Request) (interface{}, error) {
id, err := idFromRequest(r, "id")
if err != nil {
return nil, err
}
var req deleteLabelRequest
req.ID = id
return req, nil
}
func decodeGetLabelRequest(ctx context.Context, r *http.Request) (interface{}, error) {
id, err := idFromRequest(r, "id")
if err != nil {
return nil, err
}
var req getLabelRequest
req.ID = id
return req, nil
}
func decodeListLabelsRequest(ctx context.Context, r *http.Request) (interface{}, error) {
opt, err := listOptionsFromRequest(r)
if err != nil {
return nil, err
}
return listLabelsRequest{ListOptions: opt}, nil
}