File: host.go

package info (click to toggle)
golang-github-aws-aws-sdk-go-v2 1.24.1-2~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 554,032 kB
  • sloc: java: 15,941; makefile: 419; sh: 175
file content (22 lines) | stat: -rw-r--r-- 603 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package customizations

import (
	"github.com/aws/smithy-go/transport/http"
	"strings"
)

func updateS3HostForS3AccessPoint(req *http.Request) {
	updateHostPrefix(req, "s3", s3AccessPoint)
}

func updateS3HostForS3ObjectLambda(req *http.Request) {
	updateHostPrefix(req, "s3", s3ObjectLambda)
}

func updateHostPrefix(req *http.Request, oldEndpointPrefix, newEndpointPrefix string) {
	host := req.URL.Host
	if strings.HasPrefix(host, oldEndpointPrefix) {
		// For example if oldEndpointPrefix=s3 would replace to newEndpointPrefix
		req.URL.Host = newEndpointPrefix + host[len(oldEndpointPrefix):]
	}
}