You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
744 B
28 lines
744 B
package middleware
|
|
|
|
import (
|
|
"github.com/aws/smithy-go/middleware"
|
|
)
|
|
|
|
// requestIDKey is used to retrieve request id from response metadata
|
|
type requestIDKey struct{}
|
|
|
|
// SetRequestIDMetadata sets the provided request id over middleware metadata
|
|
func SetRequestIDMetadata(metadata *middleware.Metadata, id string) {
|
|
metadata.Set(requestIDKey{}, id)
|
|
}
|
|
|
|
// GetRequestIDMetadata retrieves the request id from middleware metadata
|
|
// returns string and bool indicating value of request id, whether request id was set.
|
|
func GetRequestIDMetadata(metadata middleware.Metadata) (string, bool) {
|
|
if !metadata.Has(requestIDKey{}) {
|
|
return "", false
|
|
}
|
|
|
|
v, ok := metadata.Get(requestIDKey{}).(string)
|
|
if !ok {
|
|
return "", true
|
|
}
|
|
return v, true
|
|
}
|