diff --git a/.gitignore b/.gitignore index 20fc1d7..fd573b3 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,6 @@ !.vscode/launch.json !.vscode/extensions.json +vendor + config diff --git a/app/app.go b/app/app.go index f04c079..1b64275 100644 --- a/app/app.go +++ b/app/app.go @@ -70,15 +70,21 @@ func (x *App) HTTPMode(job common.Job) (err error) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() - var r M var resp *req.Response - resp, err = x.Http.R(). + if resp, err = x.Http.R(). SetContext(ctx). SetHeaders(option.Headers). SetBody(option.Body). - SetSuccessResult(&r). - SetErrorResult(&r). - Post(option.Url) + Post(option.Url); err != nil { + x.Log.Error("Http:fail", + zap.String("key", job.Key), + zap.Int("index", job.Index), + zap.Any("headers", option.Headers), + zap.Any("body", option.Body), + zap.Error(err), + ) + return + } now := time.Now() if e := x.Transfer.Publish(ctx, "logset_jobs", transfer.Payload{ @@ -94,7 +100,7 @@ func (x *App) HTTPMode(job common.Job) (err error) { "body": option.Body, "response": M{ "status": resp.StatusCode, - "body": r, + "body": string(resp.Bytes()), }, }, XData: M{}, @@ -104,19 +110,8 @@ func (x *App) HTTPMode(job common.Job) (err error) { zap.Int("index", job.Index), zap.Any("headers", option.Headers), zap.Any("body", option.Body), - zap.Error(err), - ) - return - } - if err != nil { - x.Log.Error("Http:fail", - zap.String("key", job.Key), - zap.Int("index", job.Index), - zap.Any("headers", option.Headers), - zap.Any("body", option.Body), - zap.Error(err), + zap.Error(e), ) - // TODO: Event Callback return } x.Log.Debug("Http:ok", @@ -126,7 +121,7 @@ func (x *App) HTTPMode(job common.Job) (err error) { zap.Any("body", option.Body), zap.Any("response", M{ "status": resp.StatusCode, - "body": r, + "body": string(resp.Bytes()), }), ) return diff --git a/go.mod b/go.mod index 8829ef5..8b0fa31 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/bytedance/sonic v1.10.1 github.com/caarlos0/env/v9 v9.0.0 github.com/google/wire v0.5.0 - github.com/imroc/req/v3 v3.41.12 + github.com/imroc/req/v3 v3.42.0 github.com/mitchellh/mapstructure v1.5.0 github.com/nats-io/nats.go v1.29.0 github.com/nats-io/nkeys v0.4.4 diff --git a/go.sum b/go.sum index 73e93a6..68f3cc5 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/imroc/req/v3 v3.41.12 h1:OyPoCpVr8lpWuBwaEnqshA2xYLoxKPnjRIRVaZ+/NoQ= -github.com/imroc/req/v3 v3.41.12/go.mod h1:W7dOrfQORA9nFoj+CafIZ6P5iyk+rWdbp2sffOAvABU= +github.com/imroc/req/v3 v3.42.0 h1:g7wWva3aIJI02mrnqmXe0N5SVkXHQPsYN3Tmw2ZHn3U= +github.com/imroc/req/v3 v3.42.0/go.mod h1:W7dOrfQORA9nFoj+CafIZ6P5iyk+rWdbp2sffOAvABU= github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=