/
middleware_metadata.go
35 lines (29 loc) · 1.09 KB
/
middleware_metadata.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package http
import "context"
type (
hostnameImmutableKey struct{}
hostPrefixDisableKey struct{}
)
// GetHostnameImmutable retrieves if the endpoint hostname should be considered
// immutable or not.
func GetHostnameImmutable(ctx context.Context) (v bool) {
v, _ = ctx.Value(hostnameImmutableKey{}).(bool)
return v
}
// SetHostnameImmutable sets or modifies if the request's endpoint hostname
// should be considered immutable or not.
func SetHostnameImmutable(ctx context.Context, value bool) context.Context {
return context.WithValue(ctx, hostnameImmutableKey{}, value)
}
// DisableEndpointHostPrefix sets or modifies if the request's endpoint host
// prefixing to be disabled. If value is set to true, endpoint host prefixing
// will be disabled.
func DisableEndpointHostPrefix(ctx context.Context, value bool) context.Context {
return context.WithValue(ctx, hostPrefixDisableKey{}, value)
}
// IsEndpointHostPrefixDisabled retrieves if the hostname prefixing
// is disabled.
func IsEndpointHostPrefixDisabled(ctx context.Context) (v bool) {
v, _ = ctx.Value(hostPrefixDisableKey{}).(bool)
return v
}