当前位置: 首页>>代码示例>>Golang>>正文


Golang Request.SetBufferBody方法代码示例

本文整理汇总了Golang中github.com/swapagarwal/aws-remote/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request.Request.SetBufferBody方法的典型用法代码示例。如果您正苦于以下问题:Golang Request.SetBufferBody方法的具体用法?Golang Request.SetBufferBody怎么用?Golang Request.SetBufferBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/swapagarwal/aws-remote/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request.Request的用法示例。


在下文中一共展示了Request.SetBufferBody方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Build

// Build builds a request for the EC2 protocol.
func Build(r *request.Request) {
	body := url.Values{
		"Action":  {r.Operation.Name},
		"Version": {r.Service.APIVersion},
	}
	if err := queryutil.Parse(body, r.Params, true); err != nil {
		r.Error = awserr.New("SerializationError", "failed encoding EC2 Query request", err)
	}

	if r.ExpireTime == 0 {
		r.HTTPRequest.Method = "POST"
		r.HTTPRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
		r.SetBufferBody([]byte(body.Encode()))
	} else { // This is a pre-signed request
		r.HTTPRequest.Method = "GET"
		r.HTTPRequest.URL.RawQuery = body.Encode()
	}
}
开发者ID:swapagarwal,项目名称:aws-remote,代码行数:19,代码来源:build.go

示例2: buildBody

func buildBody(r *request.Request, v reflect.Value) {
	if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok {
		if payloadName := field.Tag.Get("payload"); payloadName != "" {
			pfield, _ := v.Type().FieldByName(payloadName)
			if ptag := pfield.Tag.Get("type"); ptag != "" && ptag != "structure" {
				payload := reflect.Indirect(v.FieldByName(payloadName))
				if payload.IsValid() && payload.Interface() != nil {
					switch reader := payload.Interface().(type) {
					case io.ReadSeeker:
						r.SetReaderBody(reader)
					case []byte:
						r.SetBufferBody(reader)
					case string:
						r.SetStringBody(reader)
					default:
						r.Error = awserr.New("SerializationError",
							"failed to encode REST request",
							fmt.Errorf("unknown payload type %s", payload.Type()))
					}
				}
			}
		}
	}
}
开发者ID:swapagarwal,项目名称:aws-remote,代码行数:24,代码来源:build.go


注:本文中的github.com/swapagarwal/aws-remote/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request.Request.SetBufferBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。