revert and update options && fix linter
This commit is contained in:
34
http.go
34
http.go
@@ -115,7 +115,7 @@ func newRequest(ctx context.Context, log logger.Logger, addr string, req client.
|
||||
|
||||
u, err = u.Parse(path)
|
||||
if err != nil {
|
||||
return nil, errors.BadRequest("go.micro.client", err.Error())
|
||||
return nil, errors.BadRequest("go.micro.client", "%+v", err)
|
||||
}
|
||||
|
||||
var nmsg interface{}
|
||||
@@ -126,12 +126,12 @@ func newRequest(ctx context.Context, log logger.Logger, addr string, req client.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, errors.BadRequest("go.micro.client", err.Error())
|
||||
return nil, errors.BadRequest("go.micro.client", "%+v", err)
|
||||
}
|
||||
|
||||
u, err = url.Parse(fmt.Sprintf("%s://%s%s", scheme, host, path))
|
||||
if err != nil {
|
||||
return nil, errors.BadRequest("go.micro.client", err.Error())
|
||||
return nil, errors.BadRequest("go.micro.client", "%+v", err)
|
||||
}
|
||||
|
||||
var cookies []*http.Cookie
|
||||
@@ -174,11 +174,11 @@ func newRequest(ctx context.Context, log logger.Logger, addr string, req client.
|
||||
for k, required := range vm {
|
||||
v, err = rutil.StructFieldByPath(msg, k)
|
||||
if err != nil {
|
||||
return nil, errors.BadRequest("go.micro.client", err.Error())
|
||||
return nil, errors.BadRequest("go.micro.client", "%+v", err)
|
||||
}
|
||||
if rutil.IsZero(v) {
|
||||
if required == "true" {
|
||||
return nil, errors.BadRequest("go.micro.client", fmt.Sprintf("required field %s not set", k))
|
||||
return nil, errors.BadRequest("go.micro.client", "required field %s not set", k)
|
||||
}
|
||||
continue
|
||||
}
|
||||
@@ -194,7 +194,7 @@ func newRequest(ctx context.Context, log logger.Logger, addr string, req client.
|
||||
|
||||
b, err := cf.Marshal(nmsg)
|
||||
if err != nil {
|
||||
return nil, errors.BadRequest("go.micro.client", err.Error())
|
||||
return nil, errors.BadRequest("go.micro.client", "%+v", err)
|
||||
}
|
||||
|
||||
var hreq *http.Request
|
||||
@@ -207,7 +207,7 @@ func newRequest(ctx context.Context, log logger.Logger, addr string, req client.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, errors.BadRequest("go.micro.client", err.Error())
|
||||
return nil, errors.BadRequest("go.micro.client", "%+v", err)
|
||||
}
|
||||
|
||||
hreq.Header = header
|
||||
@@ -230,7 +230,7 @@ func (h *httpClient) call(ctx context.Context, addr string, req client.Request,
|
||||
|
||||
cf, err := h.newCodec(ct)
|
||||
if err != nil {
|
||||
return errors.BadRequest("go.micro.client", err.Error())
|
||||
return errors.BadRequest("go.micro.client", "%+v", err)
|
||||
}
|
||||
hreq, err := newRequest(ctx, h.opts.Logger, addr, req, ct, cf, req.Body(), opts)
|
||||
if err != nil {
|
||||
@@ -243,14 +243,14 @@ func (h *httpClient) call(ctx context.Context, addr string, req client.Request,
|
||||
switch err := err.(type) {
|
||||
case *url.Error:
|
||||
if err, ok := err.Err.(net.Error); ok && err.Timeout() {
|
||||
return errors.Timeout("go.micro.client", err.Error())
|
||||
return errors.Timeout("go.micro.client", "%+v", err)
|
||||
}
|
||||
case net.Error:
|
||||
if err.Timeout() {
|
||||
return errors.Timeout("go.micro.client", err.Error())
|
||||
return errors.Timeout("go.micro.client", "%+v", err)
|
||||
}
|
||||
}
|
||||
return errors.InternalServerError("go.micro.client", err.Error())
|
||||
return errors.InternalServerError("go.micro.client", "%+v", err)
|
||||
}
|
||||
|
||||
defer hrsp.Body.Close()
|
||||
@@ -267,12 +267,12 @@ func (h *httpClient) stream(ctx context.Context, addr string, req client.Request
|
||||
// get codec
|
||||
cf, err := h.newCodec(ct)
|
||||
if err != nil {
|
||||
return nil, errors.BadRequest("go.micro.client", err.Error())
|
||||
return nil, errors.BadRequest("go.micro.client", "%+v", err)
|
||||
}
|
||||
|
||||
cc, err := (h.httpcli.Transport).(*http.Transport).DialContext(ctx, "tcp", addr)
|
||||
if err != nil {
|
||||
return nil, errors.InternalServerError("go.micro.client", fmt.Sprintf("Error dialing: %v", err))
|
||||
return nil, errors.InternalServerError("go.micro.client", "Error dialing: %v", err)
|
||||
}
|
||||
|
||||
return &httpStream{
|
||||
@@ -396,7 +396,7 @@ func (h *httpClient) Call(ctx context.Context, req client.Request, rsp interface
|
||||
// call backoff first. Someone may want an initial start delay
|
||||
t, err := callOpts.Backoff(ctx, req, i)
|
||||
if err != nil {
|
||||
return errors.InternalServerError("go.micro.client", err.Error())
|
||||
return errors.InternalServerError("go.micro.client", "%+v", err)
|
||||
}
|
||||
|
||||
// only sleep if greater than 0
|
||||
@@ -410,7 +410,7 @@ func (h *httpClient) Call(ctx context.Context, req client.Request, rsp interface
|
||||
// TODO apply any filtering here
|
||||
routes, err = h.opts.Lookup(ctx, req, callOpts)
|
||||
if err != nil {
|
||||
return errors.InternalServerError("go.micro.client", err.Error())
|
||||
return errors.InternalServerError("go.micro.client", "%+v", err)
|
||||
}
|
||||
|
||||
// balance the list of nodes
|
||||
@@ -532,7 +532,7 @@ func (h *httpClient) Stream(ctx context.Context, req client.Request, opts ...cli
|
||||
// call backoff first. Someone may want an initial start delay
|
||||
t, cerr := callOpts.Backoff(ctx, req, i)
|
||||
if cerr != nil {
|
||||
return nil, errors.InternalServerError("go.micro.client", cerr.Error())
|
||||
return nil, errors.InternalServerError("go.micro.client", "%+v", cerr)
|
||||
}
|
||||
|
||||
// only sleep if greater than 0
|
||||
@@ -546,7 +546,7 @@ func (h *httpClient) Stream(ctx context.Context, req client.Request, opts ...cli
|
||||
// TODO apply any filtering here
|
||||
routes, err = h.opts.Lookup(ctx, req, callOpts)
|
||||
if err != nil {
|
||||
return nil, errors.InternalServerError("go.micro.client", err.Error())
|
||||
return nil, errors.InternalServerError("go.micro.client", "%+v", err)
|
||||
}
|
||||
|
||||
// balance the list of nodes
|
||||
|
Reference in New Issue
Block a user