mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
715d908613
Notable refactoring: - Use stdlib "context" in place of "golang.org/x/net/context" - Go-kit no longer wraps errors, so we remove the unwrap in transport_error.go - Use MakeHandler when setting up endpoint tests (fixes test bug caught during this refactoring) Closes #1411.
31 lines
672 B
Go
31 lines
672 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
"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
|
|
}
|
|
|
|
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
|
|
}
|