mirror of
https://github.com/go-kit/kit.git
synced 2025-07-17 01:12:38 +02:00
transport/http: moved ClientResponseFunc calls after the error check but before decoding
This commit is contained in:
@ -94,10 +94,6 @@ func (c Client) Endpoint() endpoint.Endpoint {
|
||||
}
|
||||
|
||||
resp, err := ctxhttp.Do(ctx, c.client, req)
|
||||
for _, f := range c.after {
|
||||
ctx = f(ctx, resp)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, Error{Domain: DomainDo, Err: err}
|
||||
}
|
||||
@ -105,6 +101,10 @@ func (c Client) Endpoint() endpoint.Endpoint {
|
||||
defer resp.Body.Close()
|
||||
}
|
||||
|
||||
for _, f := range c.after {
|
||||
ctx = f(ctx, resp)
|
||||
}
|
||||
|
||||
response, err := c.dec(ctx, resp)
|
||||
if err != nil {
|
||||
return nil, Error{Domain: DomainDecode, Err: err}
|
||||
|
@ -19,7 +19,7 @@ type ServerResponseFunc func(context.Context, http.ResponseWriter) context.Conte
|
||||
|
||||
// ClientResponseFunc may take information from an HTTP request and make the
|
||||
// response available for consumption. ClientResponseFuncs are only executed in
|
||||
// clients, immediately after a request has been made.
|
||||
// clients, after a request has been made, but prior to it being decoded.
|
||||
type ClientResponseFunc func(context.Context, *http.Response) context.Context
|
||||
|
||||
// SetContentType returns a ResponseFunc that sets the Content-Type header to
|
||||
|
Reference in New Issue
Block a user