File: context.go

package info (click to toggle)
golang-github-aws-aws-sdk-go-v2 1.30.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie, trixie-backports
  • size: 662,428 kB
  • sloc: java: 16,875; makefile: 432; sh: 175
file content (21 lines) | stat: -rw-r--r-- 545 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package customizations

import (
	"context"

	"github.com/aws/smithy-go/middleware"
)

type bucketKey struct{}

// SetBucket stores a bucket name within the request context, which is required
// for a variety of custom S3 behaviors.
func SetBucket(ctx context.Context, bucket string) context.Context {
	return middleware.WithStackValue(ctx, bucketKey{}, bucket)
}

// GetBucket retrieves a stored bucket name within a context.
func GetBucket(ctx context.Context) string {
	v, _ := middleware.GetStackValue(ctx, bucketKey{}).(string)
	return v
}