diff --git a/session_test.go b/session_test.go index 1911aa6..fc68714 100644 --- a/session_test.go +++ b/session_test.go @@ -76,7 +76,7 @@ func TestSession_Post(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { ses := NewSession() - got, err := ses.Post("http://httpbin.org/post").SetBody(tt.args.params...).Execute() + got, err := ses.Post("http://httpbin.org/post").AutoSetBody(tt.args.params...).Execute() if err != nil { t.Errorf("Metchod error = %v", err) @@ -127,7 +127,7 @@ func TestSession_Setparams(t *testing.T) { t.Run(tt.name, func(t *testing.T) { ses := NewSession() - got, err := ses.Post("http://httpbin.org/post").SetBody(tt.args.params...).Execute() + got, err := ses.Post("http://httpbin.org/post").AutoSetBody(tt.args.params...).Execute() if (err != nil) != tt.wantErr { t.Errorf("Metchod error = %v, wantErr %v", err, tt.wantErr) return @@ -169,7 +169,7 @@ func TestSession_PostUploadFile(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { ses := NewSession() - got, err := ses.Post("http://httpbin.org/post").SetBody(tt.args.params, TypeFormData).Execute() + got, err := ses.Post("http://httpbin.org/post").AutoSetBody(tt.args.params, TypeFormData).Execute() if err != nil { t.Errorf("Metchod error = %v", err) @@ -213,7 +213,7 @@ func TestSession_Put(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { ses := NewSession() - got, err := ses.Put("http://httpbin.org/put").SetBody(tt.args.params, TypeFormData).Execute() + got, err := ses.Put("http://httpbin.org/put").AutoSetBody(tt.args.params, TypeFormData).Execute() if err != nil { t.Errorf("Metchod error = %v", err) @@ -257,7 +257,7 @@ func TestSession_Patch(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { ses := NewSession() - got, err := ses.Patch("http://httpbin.org/patch").SetBody(tt.args.params, TypeFormData).Execute() + got, err := ses.Patch("http://httpbin.org/patch").AutoSetBody(tt.args.params, TypeFormData).Execute() if err != nil { t.Errorf("Metchod error = %v", err) diff --git a/workflow.go b/workflow.go index b08819f..2029893 100644 --- a/workflow.go +++ b/workflow.go @@ -185,7 +185,18 @@ func (wf *Workflow) SetURLRawPath(path string) *Workflow { } // SetBody 参数设置 -func (wf *Workflow) SetBody(params ...interface{}) *Workflow { +func (wf *Workflow) SetBody(body IBody) *Workflow { + wf.Body = body + return wf +} + +// GetBody 参数设置 +func (wf *Workflow) GetBody(body IBody) IBody { + return wf.Body +} + +// AutoSetBody 参数设置 +func (wf *Workflow) AutoSetBody(params ...interface{}) *Workflow { if params != nil { plen := len(params)