1
0
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:
Geoff Berger
2016-06-07 16:58:09 -06:00
parent 380dd50bc2
commit 84ef3c68a7
2 changed files with 5 additions and 5 deletions

View File

@ -94,10 +94,6 @@ func (c Client) Endpoint() endpoint.Endpoint {
} }
resp, err := ctxhttp.Do(ctx, c.client, req) resp, err := ctxhttp.Do(ctx, c.client, req)
for _, f := range c.after {
ctx = f(ctx, resp)
}
if err != nil { if err != nil {
return nil, Error{Domain: DomainDo, Err: err} return nil, Error{Domain: DomainDo, Err: err}
} }
@ -105,6 +101,10 @@ func (c Client) Endpoint() endpoint.Endpoint {
defer resp.Body.Close() defer resp.Body.Close()
} }
for _, f := range c.after {
ctx = f(ctx, resp)
}
response, err := c.dec(ctx, resp) response, err := c.dec(ctx, resp)
if err != nil { if err != nil {
return nil, Error{Domain: DomainDecode, Err: err} return nil, Error{Domain: DomainDecode, Err: err}

View File

@ -19,7 +19,7 @@ type ServerResponseFunc func(context.Context, http.ResponseWriter) context.Conte
// ClientResponseFunc may take information from an HTTP request and make the // ClientResponseFunc may take information from an HTTP request and make the
// response available for consumption. ClientResponseFuncs are only executed in // 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 type ClientResponseFunc func(context.Context, *http.Response) context.Context
// SetContentType returns a ResponseFunc that sets the Content-Type header to // SetContentType returns a ResponseFunc that sets the Content-Type header to