IOBODY -> GETIOBODY

This commit is contained in:
huangsimin 2018-11-21 16:29:13 +08:00
parent 8a6e29bc8a
commit 9d6dee25c9
2 changed files with 12 additions and 13 deletions

10
base.go
View File

@ -12,17 +12,17 @@ func buildBodyRequest(wf *Workflow) *http.Request {
var err error
contentType := ""
if wf.Body.IOBody() == nil {
if wf.Body.GetIOBody() == nil {
req, err = http.NewRequest(wf.Method, wf.GetRawURL(), nil)
} else {
var bodybuf *bytes.Buffer
switch wf.Body.IOBody().(type) {
switch wf.Body.GetIOBody().(type) {
case []byte:
bodybuf = bytes.NewBuffer(wf.Body.IOBody().([]byte))
bodybuf = bytes.NewBuffer(wf.Body.GetIOBody().([]byte))
case *bytes.Buffer:
bodybuf = bytes.NewBuffer(wf.Body.IOBody().(*bytes.Buffer).Bytes())
bodybuf = bytes.NewBuffer(wf.Body.GetIOBody().(*bytes.Buffer).Bytes())
default:
panic(errors.New("the type is not exist, type is" + reflect.TypeOf(wf.Body.IOBody).String()))
panic(errors.New("the type is not exist, type is" + reflect.TypeOf(wf.Body.GetIOBody()).String()))
}
req, err = http.NewRequest(wf.Method, wf.GetRawURL(), bodybuf)
}

View File

@ -36,8 +36,8 @@ func (body *Body) SetIOBody(iobody interface{}) {
body.ioBody = iobody
}
// IOBody 获取ioBody值
func (body *Body) IOBody() interface{} {
// GetIOBody 获取ioBody值
func (body *Body) GetIOBody() interface{} {
return body.ioBody
}
@ -70,16 +70,15 @@ func (body *Body) AddContentType(ct string) {
// IBody 相关参数结构
type IBody interface {
// Query map[string][]string
IOBody() interface{}
// SetIOBody
// GetIOBody 获取iobody data
GetIOBody() interface{}
// SetIOBody 设置iobody data
SetIOBody(iobody interface{})
// Files []UploadFile
// ContentType 返回包括 Prefix 所有的ContentType
ContentType() string
// AppendContent
AddContentType(ct string)
// AddPrefix 添加 Prefix
// SetPrefix 设置 Prefix; 唯一前缀
SetPrefix(ct string)
}