Sha256: 06b7bafbc31a587c736e86ca8c2ae5037dfa16b105f7c5fba0c45d94205b408e

Contents?: true

Size: 1.44 KB

Versions: 16

Compression:

Stored size: 1.44 KB

Contents

package middleware

import (
	"context"

	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

// AddRequestIDRetrieverMiddleware adds request id retriever middleware
func AddRequestIDRetrieverMiddleware(stack *middleware.Stack) error {
	// add error wrapper middleware before operation deserializers so that it can wrap the error response
	// returned by operation deserializers
	return stack.Deserialize.Insert(&requestIDRetriever{}, "OperationDeserializer", middleware.Before)
}

type requestIDRetriever struct {
}

// ID returns the middleware identifier
func (m *requestIDRetriever) ID() string {
	return "RequestIDRetriever"
}

func (m *requestIDRetriever) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) (
	out middleware.DeserializeOutput, metadata middleware.Metadata, err error,
) {
	out, metadata, err = next.HandleDeserialize(ctx, in)

	resp, ok := out.RawResponse.(*smithyhttp.Response)
	if !ok {
		// No raw response to wrap with.
		return out, metadata, err
	}

	// Different header which can map to request id
	requestIDHeaderList := []string{"X-Amzn-Requestid", "X-Amz-RequestId"}

	for _, h := range requestIDHeaderList {
		// check for headers known to contain Request id
		if v := resp.Header.Get(h); len(v) != 0 {
			// set reqID on metadata for successful responses.
			SetRequestIDMetadata(&metadata, v)
			break
		}
	}

	return out, metadata, err
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby_snowflake_client-1.3.7 ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go
ruby_snowflake_client-1.3.6 ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go
ruby_snowflake_client-1.3.5 ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go
ruby_snowflake_client-1.3.4 ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go
ruby_snowflake_client-1.3.4.pre.debug ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go
ruby_snowflake_client-1.3.3.pre.debug ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go
ruby_snowflake_client-1.3.2 ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go
ruby_snowflake_client-1.3.1 ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go
ruby_snowflake_client-1.3.0 ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go
ruby_snowflake_client-1.2.1 ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go
ruby_snowflake_client-1.2.0 ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go
ruby_snowflake_client-1.1.1 ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go
ruby_snowflake_client-1.1.0 ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go
ruby_snowflake_client-1.0.2 ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go
ruby_snowflake_client-1.0.1 ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go
ruby_snowflake_client-1.0.0 ext/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/request_id_retriever.go