2016-10-06 00:10:44 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
2017-03-15 15:55:30 +00:00
|
|
|
"context"
|
2016-10-06 00:10:44 +00:00
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2016-10-13 18:21:47 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|