8 // DecodeRequestFunc extracts a user-domain request object from an HTTP
9 // request object. It's designed to be used in HTTP servers, for server-side
10 // endpoints. One straightforward DecodeRequestFunc could be something that
11 // JSON decodes from the request body to the concrete response type.
12 type DecodeRequestFunc func(context.Context, *http.Request) (request interface{}, err error)
14 // EncodeRequestFunc encodes the passed request object into the HTTP request
15 // object. It's designed to be used in HTTP clients, for client-side
16 // endpoints. One straightforward EncodeRequestFunc could something that JSON
17 // encodes the object directly to the request body.
18 type EncodeRequestFunc func(context.Context, *http.Request, interface{}) error
20 // EncodeResponseFunc encodes the passed response object to the HTTP response
21 // writer. It's designed to be used in HTTP servers, for server-side
22 // endpoints. One straightforward EncodeResponseFunc could be something that
23 // JSON encodes the object directly to the response body.
24 type EncodeResponseFunc func(context.Context, http.ResponseWriter, interface{}) error
26 // DecodeResponseFunc extracts a user-domain response object from an HTTP
27 // response object. It's designed to be used in HTTP clients, for client-side
28 // endpoints. One straightforward DecodeResponseFunc could be something that
29 // JSON decodes from the response body to the concrete response type.
30 type DecodeResponseFunc func(context.Context, *http.Response) (response interface{}, err error)