OSDN Git Service

delete miner
[bytom/vapor.git] / vendor / github.com / go-kit / kit / transport / http / encode_decode.go
1 package http
2
3 import (
4         "context"
5         "net/http"
6 )
7
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)
13
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
19
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
25
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)