Skip to content

Commit 7c74157

Browse files
committed
add blurb on disabling endpoint prefix
1 parent 6ae12f1 commit 7c74157

File tree

208 files changed

+1276
-968
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+1276
-968
lines changed

content/en/docs/configuring-sdk/endpoints.md

+79
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ When migrating from v1 to v2 of endpoint resolution, the following general princ
334334
* Returning an Endpoint with HostnameImmutable set to `true` is roughly
335335
equivalent to implementing an `EndpointResolverV2` which returns the
336336
originally returned URL from v1.
337+
* The primary exception is for operations with modeled endpoint prefixes. A
338+
note on this is given further down.
337339

338340
Examples for these cases are provided below.
339341

@@ -344,6 +346,16 @@ still be set for immutable endpoints returned via v1 code, but the same will
344346
not be done for v2.
345347
{{% /pageinfo %}}
346348

349+
### Note on host prefixes
350+
351+
Some operations are modeled with host prefixes to be prepended to the resolved
352+
endpoint. This behavior must work in tandem with the output of
353+
ResolveEndpointV2 and therefore the host prefix will still be applied to that
354+
result.
355+
356+
You can manually disable endpoint host prefixing by applying a middleware, see
357+
the examples section.
358+
347359
### Examples
348360

349361
#### Mutable endpoint
@@ -400,3 +412,70 @@ client := svc.NewFromConfig(cfg, func (o *svc.Options) {
400412
})
401413
```
402414

415+
#### Disable host prefix
416+
417+
```go
418+
import (
419+
"context"
420+
"fmt"
421+
"net/url"
422+
423+
"github.com/aws/aws-sdk-go-v2/aws"
424+
"github.com/aws/aws-sdk-go-v2/config"
425+
"github.com/aws/aws-sdk-go-v2/service/<service>"
426+
smithyendpoints "github.com/aws/smithy-go/endpoints"
427+
"github.com/aws/smithy-go/middleware"
428+
smithyhttp "github.com/aws/smithy-go/transport/http"
429+
)
430+
431+
// disableEndpointPrefix applies the flag that will prevent any
432+
// operation-specific host prefix from being applied
433+
type disableEndpointPrefix struct{}
434+
435+
func (disableEndpointPrefix) ID() string { return "disableEndpointPrefix" }
436+
437+
func (disableEndpointPrefix) HandleInitialize(
438+
ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler,
439+
) (middleware.InitializeOutput, middleware.Metadata, error) {
440+
ctx = smithyhttp.SetHostnameImmutable(ctx, true)
441+
return next.HandleInitialize(ctx, in)
442+
}
443+
444+
func addDisableEndpointPrefix(o *<service>.Options) {
445+
o.APIOptions = append(o.APIOptions, (func(stack *middleware.Stack) error {
446+
return stack.Initialize.Add(disableEndpointPrefix{}, middleware.After)
447+
}))
448+
}
449+
450+
type staticResolver struct{}
451+
452+
func (staticResolver) ResolveEndpoint(ctx context.Context, params <service>.EndpointParameters) (
453+
smithyendpoints.Endpoint, error,
454+
) {
455+
u, err := url.Parse("https://custom.endpoint.api/")
456+
if err != nil {
457+
return smithyendpoints.Endpoint{}, err
458+
}
459+
460+
return smithyendpoints.Endpoint{URI: *u}, nil
461+
}
462+
463+
464+
func main() {
465+
cfg, err := config.LoadDefaultConfig(context.Background())
466+
if err != nil {
467+
panic(err)
468+
}
469+
470+
svc := <service>.NewFromConfig(cfg, func(o *<service>.Options) {
471+
o.EndpointResolverV2 = staticResolver{}
472+
})
473+
474+
_, err = svc.<Operation>(context.Background(), &<service>.<OperationInput>{ /* ... */ },
475+
addDisableEndpointPrefix)
476+
if err != nil {
477+
panic(err)
478+
}
479+
}
480+
```
481+

docs/404.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!doctype html>
22
<html itemscope itemtype="http://schema.org/WebPage" lang="en" class="no-js">
3-
<head><script src="/aws-sdk-go-v2/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=aws-sdk-go-v2/livereload" data-no-instant defer></script>
3+
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
66
<meta name="generator" content="Hugo 0.115.4">
@@ -23,7 +23,7 @@
2323
<meta property="og:title" content="404 Page not found" />
2424
<meta property="og:description" content="The AWS SDK for Go V2 provides APIs and utilities that developers can use to build Go applications that use AWS services." />
2525
<meta property="og:type" content="website" />
26-
<meta property="og:url" content="http://localhost:1313/aws-sdk-go-v2/404.html" />
26+
<meta property="og:url" content="https://aws.github.io/aws-sdk-go-v2/404.html" />
2727
<meta itemprop="name" content="404 Page not found">
2828
<meta itemprop="description" content="The AWS SDK for Go V2 provides APIs and utilities that developers can use to build Go applications that use AWS services."><meta name="twitter:card" content="summary"/>
2929
<meta name="twitter:title" content="404 Page not found"/>
@@ -99,7 +99,7 @@
9999
aria-label="Search this site…"
100100
autocomplete="off"
101101

102-
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.30b245754e63db1f94dcbaa3ba0f9915.json"
102+
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.1ed5201c9429d6d49ab1e6d6c5e5409e.json"
103103
data-offline-search-base-href="/"
104104
data-offline-search-max-results="10"
105105
>

docs/docs/cloud9-go/index.html

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!doctype html>
22
<html itemscope itemtype="http://schema.org/WebPage" lang="en" class="no-js">
3-
<head><script src="/aws-sdk-go-v2/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=aws-sdk-go-v2/livereload" data-no-instant defer></script>
3+
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
66
<meta name="generator" content="Hugo 0.115.4">
@@ -24,7 +24,7 @@
2424
<meta property="og:title" content="Using AWS Cloud9 with the AWS SDK for Go V2" />
2525
<meta property="og:description" content="You can use AWS Cloud9 with the AWS SDK for Go V2 to write and run your Go code using just a browser. AWS Cloud9 includes tools such as a code editor and terminal. The AWS Cloud9 IDE is cloud based, so you can work on your projects from your office, home, or anywhere using an internet-connected machine. For general information about AWS Cloud9, see the AWS Cloud9 User Guide." />
2626
<meta property="og:type" content="article" />
27-
<meta property="og:url" content="http://localhost:1313/aws-sdk-go-v2/docs/cloud9-go/" /><meta property="article:section" content="docs" />
27+
<meta property="og:url" content="https://aws.github.io/aws-sdk-go-v2/docs/cloud9-go/" /><meta property="article:section" content="docs" />
2828
<meta property="article:published_time" content="2020-11-12T00:00:00+00:00" />
2929
<meta property="article:modified_time" content="2021-04-23T01:04:37+02:00" />
3030
<meta itemprop="name" content="Using AWS Cloud9 with the AWS SDK for Go V2">
@@ -105,7 +105,7 @@
105105
aria-label="Search this site…"
106106
autocomplete="off"
107107

108-
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.30b245754e63db1f94dcbaa3ba0f9915.json"
108+
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.1ed5201c9429d6d49ab1e6d6c5e5409e.json"
109109
data-offline-search-base-href="/"
110110
data-offline-search-max-results="10"
111111
>
@@ -127,7 +127,7 @@
127127
aria-label="Search this site…"
128128
autocomplete="off"
129129

130-
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.30b245754e63db1f94dcbaa3ba0f9915.json"
130+
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.1ed5201c9429d6d49ab1e6d6c5e5409e.json"
131131
data-offline-search-base-href="/"
132132
data-offline-search-max-results="10"
133133
>
@@ -475,10 +475,10 @@
475475
<nav aria-label="breadcrumb" class="td-breadcrumbs">
476476
<ol class="breadcrumb">
477477
<li class="breadcrumb-item">
478-
<a href="http://localhost:1313/aws-sdk-go-v2/docs/">Developer Guide</a>
478+
<a href="https://aws.github.io/aws-sdk-go-v2/docs/">Developer Guide</a>
479479
</li>
480480
<li class="breadcrumb-item active" aria-current="page">
481-
<a href="http://localhost:1313/aws-sdk-go-v2/docs/cloud9-go/" aria-disabled="true" class="btn-link disabled">Using Cloud9 with the SDK</a>
481+
<a href="https://aws.github.io/aws-sdk-go-v2/docs/cloud9-go/" aria-disabled="true" class="btn-link disabled">Using Cloud9 with the SDK</a>
482482
</li>
483483
</ol>
484484
</nav>
@@ -576,7 +576,7 @@ <h2 id="InstallUpgradeGo">Installing/Upgrading AWS Cloud9 Go Version</h2>
576576

577577

578578
<div class="text-muted mt-5 pt-3 border-top">
579-
Last modified April 23, 2021: <a href="https://github.com/aws/aws-sdk-go-v2/commit/6c3cbc2a767107ac17f06d43c815f2ea3bb57484">Fixing broken links, correcting typos (#1236) (6c3cbc2)</a>
579+
Last modified April 23, 2021: <a href="https://github.com/aws/aws-sdk-go-v2/commit/6c3cbc2a767107ac17f06d43c815f2ea3bb57484">Fixing broken links, correcting typos (#1236) (6c3cbc2a76)</a>
580580
</div>
581581

582582
</div>

docs/docs/code-examples/cloudwatch/createcustommetric/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head><script src="/aws-sdk-go-v2/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=aws-sdk-go-v2/livereload" data-no-instant defer></script>
3+
<head>
44
<meta charset="UTF-8">
55
<meta name="robots" content="noindex">
66
<meta http-equiv="Refresh" content="0; url='https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2"/>

docs/docs/code-examples/cloudwatch/createcustommetric/index.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
22
<channel>
33
<title>AWS SDK for Go V2 – CreateCustomMetricv2</title>
4-
<link>http://localhost:1313/aws-sdk-go-v2/docs/code-examples/cloudwatch/createcustommetric/</link>
4+
<link>https://aws.github.io/aws-sdk-go-v2/docs/code-examples/cloudwatch/createcustommetric/</link>
55
<description>Recent content in CreateCustomMetricv2 on AWS SDK for Go V2</description>
66
<generator>Hugo -- gohugo.io</generator>
77
<language>en</language>
88

9-
<atom:link href="http://localhost:1313/aws-sdk-go-v2/docs/code-examples/cloudwatch/createcustommetric/index.xml" rel="self" type="application/rss+xml" />
9+
<atom:link href="https://aws.github.io/aws-sdk-go-v2/docs/code-examples/cloudwatch/createcustommetric/index.xml" rel="self" type="application/rss+xml" />
1010

1111

1212

docs/docs/code-examples/cloudwatch/createenablemetricalarm/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head><script src="/aws-sdk-go-v2/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=aws-sdk-go-v2/livereload" data-no-instant defer></script>
3+
<head>
44
<meta charset="UTF-8">
55
<meta name="robots" content="noindex">
66
<meta http-equiv="Refresh" content="0; url='https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2"/>

docs/docs/code-examples/cloudwatch/createenablemetricalarm/index.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
22
<channel>
33
<title>AWS SDK for Go V2 – CreateEnableMetricAlarmv2</title>
4-
<link>http://localhost:1313/aws-sdk-go-v2/docs/code-examples/cloudwatch/createenablemetricalarm/</link>
4+
<link>https://aws.github.io/aws-sdk-go-v2/docs/code-examples/cloudwatch/createenablemetricalarm/</link>
55
<description>Recent content in CreateEnableMetricAlarmv2 on AWS SDK for Go V2</description>
66
<generator>Hugo -- gohugo.io</generator>
77
<language>en</language>
88

9-
<atom:link href="http://localhost:1313/aws-sdk-go-v2/docs/code-examples/cloudwatch/createenablemetricalarm/index.xml" rel="self" type="application/rss+xml" />
9+
<atom:link href="https://aws.github.io/aws-sdk-go-v2/docs/code-examples/cloudwatch/createenablemetricalarm/index.xml" rel="self" type="application/rss+xml" />
1010

1111

1212

docs/docs/code-examples/cloudwatch/describealarms/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head><script src="/aws-sdk-go-v2/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=aws-sdk-go-v2/livereload" data-no-instant defer></script>
3+
<head>
44
<meta charset="UTF-8">
55
<meta name="robots" content="noindex">
66
<meta http-equiv="Refresh" content="0; url='https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2"/>

docs/docs/code-examples/cloudwatch/describealarms/index.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
22
<channel>
33
<title>AWS SDK for Go V2 – DescribeAlarmsv2</title>
4-
<link>http://localhost:1313/aws-sdk-go-v2/docs/code-examples/cloudwatch/describealarms/</link>
4+
<link>https://aws.github.io/aws-sdk-go-v2/docs/code-examples/cloudwatch/describealarms/</link>
55
<description>Recent content in DescribeAlarmsv2 on AWS SDK for Go V2</description>
66
<generator>Hugo -- gohugo.io</generator>
77
<language>en</language>
88

9-
<atom:link href="http://localhost:1313/aws-sdk-go-v2/docs/code-examples/cloudwatch/describealarms/index.xml" rel="self" type="application/rss+xml" />
9+
<atom:link href="https://aws.github.io/aws-sdk-go-v2/docs/code-examples/cloudwatch/describealarms/index.xml" rel="self" type="application/rss+xml" />
1010

1111

1212

docs/docs/code-examples/cloudwatch/disablealarm/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head><script src="/aws-sdk-go-v2/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=aws-sdk-go-v2/livereload" data-no-instant defer></script>
3+
<head>
44
<meta charset="UTF-8">
55
<meta name="robots" content="noindex">
66
<meta http-equiv="Refresh" content="0; url='https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2"/>

docs/docs/code-examples/cloudwatch/disablealarm/index.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
22
<channel>
33
<title>AWS SDK for Go V2 – DisableAlarmv2</title>
4-
<link>http://localhost:1313/aws-sdk-go-v2/docs/code-examples/cloudwatch/disablealarm/</link>
4+
<link>https://aws.github.io/aws-sdk-go-v2/docs/code-examples/cloudwatch/disablealarm/</link>
55
<description>Recent content in DisableAlarmv2 on AWS SDK for Go V2</description>
66
<generator>Hugo -- gohugo.io</generator>
77
<language>en</language>
88

9-
<atom:link href="http://localhost:1313/aws-sdk-go-v2/docs/code-examples/cloudwatch/disablealarm/index.xml" rel="self" type="application/rss+xml" />
9+
<atom:link href="https://aws.github.io/aws-sdk-go-v2/docs/code-examples/cloudwatch/disablealarm/index.xml" rel="self" type="application/rss+xml" />
1010

1111

1212

docs/docs/code-examples/cloudwatch/index.html

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<!doctype html>
22
<html itemscope itemtype="http://schema.org/WebPage" lang="en" class="no-js">
3-
<head><script src="/aws-sdk-go-v2/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=aws-sdk-go-v2/livereload" data-no-instant defer></script>
3+
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
66
<meta name="generator" content="Hugo 0.115.4">
7-
<link rel="alternate" type="application/rss&#43;xml" href="http://localhost:1313/aws-sdk-go-v2/docs/code-examples/cloudwatch/index.xml">
7+
<link rel="alternate" type="application/rss&#43;xml" href="https://aws.github.io/aws-sdk-go-v2/docs/code-examples/cloudwatch/index.xml">
88
<meta name="robots" content="index, follow">
99

1010

@@ -25,7 +25,7 @@
2525
<meta property="og:title" content="Amazon CloudWatch Examples" />
2626
<meta property="og:description" content="The AWS SDK for Go V2 provides APIs and utilities that developers can use to build Go applications that use AWS services." />
2727
<meta property="og:type" content="website" />
28-
<meta property="og:url" content="http://localhost:1313/aws-sdk-go-v2/docs/code-examples/cloudwatch/" />
28+
<meta property="og:url" content="https://aws.github.io/aws-sdk-go-v2/docs/code-examples/cloudwatch/" />
2929
<meta itemprop="name" content="Amazon CloudWatch Examples">
3030
<meta itemprop="description" content="The AWS SDK for Go V2 provides APIs and utilities that developers can use to build Go applications that use AWS services."><meta name="twitter:card" content="summary"/>
3131
<meta name="twitter:title" content="Amazon CloudWatch Examples"/>
@@ -101,7 +101,7 @@
101101
aria-label="Search this site…"
102102
autocomplete="off"
103103

104-
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.30b245754e63db1f94dcbaa3ba0f9915.json"
104+
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.1ed5201c9429d6d49ab1e6d6c5e5409e.json"
105105
data-offline-search-base-href="/"
106106
data-offline-search-max-results="10"
107107
>
@@ -123,7 +123,7 @@
123123
aria-label="Search this site…"
124124
autocomplete="off"
125125

126-
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.30b245754e63db1f94dcbaa3ba0f9915.json"
126+
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.1ed5201c9429d6d49ab1e6d6c5e5409e.json"
127127
data-offline-search-base-href="/"
128128
data-offline-search-max-results="10"
129129
>
@@ -453,13 +453,13 @@
453453
<nav aria-label="breadcrumb" class="td-breadcrumbs">
454454
<ol class="breadcrumb">
455455
<li class="breadcrumb-item">
456-
<a href="http://localhost:1313/aws-sdk-go-v2/docs/">Developer Guide</a>
456+
<a href="https://aws.github.io/aws-sdk-go-v2/docs/">Developer Guide</a>
457457
</li>
458458
<li class="breadcrumb-item">
459-
<a href="http://localhost:1313/aws-sdk-go-v2/docs/code-examples/">Code Examples</a>
459+
<a href="https://aws.github.io/aws-sdk-go-v2/docs/code-examples/">Code Examples</a>
460460
</li>
461461
<li class="breadcrumb-item active" aria-current="page">
462-
<a href="http://localhost:1313/aws-sdk-go-v2/docs/code-examples/cloudwatch/" aria-disabled="true" class="btn-link disabled">Amazon CloudWatch</a>
462+
<a href="https://aws.github.io/aws-sdk-go-v2/docs/code-examples/cloudwatch/" aria-disabled="true" class="btn-link disabled">Amazon CloudWatch</a>
463463
</li>
464464
</ol>
465465
</nav>
@@ -549,7 +549,7 @@ <h5>
549549

550550

551551
<div class="text-muted mt-5 pt-3 border-top">
552-
Last modified January 14, 2021: <a href="https://github.com/aws/aws-sdk-go-v2/commit/6b77d0a0af50a1fdb5a265b225530fc50386a068">Added code examples from AWS SDK docs repo (#1015) (6b77d0a)</a>
552+
Last modified January 14, 2021: <a href="https://github.com/aws/aws-sdk-go-v2/commit/6b77d0a0af50a1fdb5a265b225530fc50386a068">Added code examples from AWS SDK docs repo (#1015) (6b77d0a0af)</a>
553553
</div>
554554

555555
</div>

0 commit comments

Comments
 (0)