當前位置: 首頁>>代碼示例>>Golang>>正文


Golang service.NewRequest函數代碼示例

本文整理匯總了Golang中github.com/tetrafolium/aws-sdk-go/aws/service.NewRequest函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewRequest函數的具體用法?Golang NewRequest怎麽用?Golang NewRequest使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewRequest函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: newRequest

// newRequest creates a new request for a CloudWatchLogs operation and runs any
// custom request initialization.
func (c *CloudWatchLogs) newRequest(op *service.Operation, params, data interface{}) *service.Request {
	req := service.NewRequest(c.Service, op, params, data)

	// Run custom request initialization if present
	if initRequest != nil {
		initRequest(req)
	}

	return req
}
開發者ID:tetrafolium,項目名稱:aws-sdk-go,代碼行數:12,代碼來源:service.go

示例2: TestEndpoint

func TestEndpoint(t *testing.T) {
	c := ec2metadata.New(&ec2metadata.Config{})
	op := &service.Operation{
		Name:       "GetMetadata",
		HTTPMethod: "GET",
		HTTPPath:   path.Join("/", "meta-data", "testpath"),
	}

	req := service.NewRequest(c.Service, op, nil, nil)
	assert.Equal(t, "http://169.254.169.254/latest", req.Endpoint)
	assert.Equal(t, "http://169.254.169.254/latest/meta-data/testpath", req.HTTPRequest.URL.String())
}
開發者ID:tetrafolium,項目名稱:aws-sdk-go,代碼行數:12,代碼來源:api_test.go

示例3: GetMetadata

// GetMetadata uses the path provided to request
func (c *Client) GetMetadata(p string) (string, error) {
	op := &service.Operation{
		Name:       "GetMetadata",
		HTTPMethod: "GET",
		HTTPPath:   path.Join("/", "meta-data", p),
	}

	output := &metadataOutput{}
	req := service.NewRequest(c.Service, op, nil, output)

	return output.Content, req.Send()
}
開發者ID:tetrafolium,項目名稱:aws-sdk-go,代碼行數:13,代碼來源:api.go

示例4: TestResignRequestExpiredCreds

func TestResignRequestExpiredCreds(t *testing.T) {
	creds := credentials.NewStaticCredentials("AKID", "SECRET", "SESSION")
	r := service.NewRequest(
		service.NewService(&aws.Config{Credentials: creds}),
		&service.Operation{
			Name:       "BatchGetItem",
			HTTPMethod: "POST",
			HTTPPath:   "/",
		},
		nil,
		nil,
	)
	Sign(r)
	querySig := r.HTTPRequest.Header.Get("Authorization")

	creds.Expire()

	Sign(r)
	assert.NotEqual(t, querySig, r.HTTPRequest.Header.Get("Authorization"))
}
開發者ID:tetrafolium,項目名稱:aws-sdk-go,代碼行數:20,代碼來源:v4_test.go

示例5: TestIgnoreResignRequestWithValidCreds

func TestIgnoreResignRequestWithValidCreds(t *testing.T) {
	r := service.NewRequest(
		service.NewService(&aws.Config{
			Credentials: credentials.NewStaticCredentials("AKID", "SECRET", "SESSION"),
			Region:      aws.String("us-west-2"),
		}),
		&service.Operation{
			Name:       "BatchGetItem",
			HTTPMethod: "POST",
			HTTPPath:   "/",
		},
		nil,
		nil,
	)

	Sign(r)
	sig := r.HTTPRequest.Header.Get("Authorization")

	Sign(r)
	assert.Equal(t, sig, r.HTTPRequest.Header.Get("Authorization"))
}
開發者ID:tetrafolium,項目名稱:aws-sdk-go,代碼行數:21,代碼來源:v4_test.go

示例6: TestAnonymousCredentials

func TestAnonymousCredentials(t *testing.T) {
	r := service.NewRequest(
		service.NewService(&aws.Config{Credentials: credentials.AnonymousCredentials}),
		&service.Operation{
			Name:       "BatchGetItem",
			HTTPMethod: "POST",
			HTTPPath:   "/",
		},
		nil,
		nil,
	)
	Sign(r)

	urlQ := r.HTTPRequest.URL.Query()
	assert.Empty(t, urlQ.Get("X-Amz-Signature"))
	assert.Empty(t, urlQ.Get("X-Amz-Credential"))
	assert.Empty(t, urlQ.Get("X-Amz-SignedHeaders"))
	assert.Empty(t, urlQ.Get("X-Amz-Date"))

	hQ := r.HTTPRequest.Header
	assert.Empty(t, hQ.Get("Authorization"))
	assert.Empty(t, hQ.Get("X-Amz-Date"))
}
開發者ID:tetrafolium,項目名稱:aws-sdk-go,代碼行數:23,代碼來源:v4_test.go

示例7: TestPreResignRequestExpiredCreds

func TestPreResignRequestExpiredCreds(t *testing.T) {
	provider := &credentials.StaticProvider{credentials.Value{"AKID", "SECRET", "SESSION"}}
	creds := credentials.NewCredentials(provider)
	r := service.NewRequest(
		service.NewService(&aws.Config{Credentials: creds}),
		&service.Operation{
			Name:       "BatchGetItem",
			HTTPMethod: "POST",
			HTTPPath:   "/",
		},
		nil,
		nil,
	)
	r.ExpireTime = time.Minute * 10

	Sign(r)
	querySig := r.HTTPRequest.URL.Query().Get("X-Amz-Signature")

	creds.Expire()
	r.Time = time.Now().Add(time.Hour * 48)

	Sign(r)
	assert.NotEqual(t, querySig, r.HTTPRequest.URL.Query().Get("X-Amz-Signature"))
}
開發者ID:tetrafolium,項目名稱:aws-sdk-go,代碼行數:24,代碼來源:v4_test.go

示例8: newRequest

// newRequest creates a new request for a OutputService12ProtocolTest operation and runs any
// custom request initialization.
func (c *OutputService12ProtocolTest) newRequest(op *service.Operation, params, data interface{}) *service.Request {
	req := service.NewRequest(c.Service, op, params, data)

	return req
}
開發者ID:tetrafolium,項目名稱:aws-sdk-go,代碼行數:7,代碼來源:unmarshal_test.go


注:本文中的github.com/tetrafolium/aws-sdk-go/aws/service.NewRequest函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。