mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
97de2bc5aa
close #403 close #404 close #412
45 lines
979 B
Go
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
|
|
}
|