14 // newContextWithToken sets the token in a new context and returns the context.
15 func newContextWithToken(ctx context.Context, token string) context.Context {
16 return context.WithValue(ctx, tokenKey, token)
19 // Token returns the token stored in the context, if there is one.
20 func Token(ctx context.Context) string {
21 t, ok := ctx.Value(tokenKey).(string)
28 // newContextWithLocalhost sets the localhost flag to `true` in a new context
29 // and returns that context.
30 func newContextWithLocalhost(ctx context.Context) context.Context {
31 return context.WithValue(ctx, localhostKey, true)
34 // Localhost returns true if the localhost flag has been set.
35 func Localhost(ctx context.Context) bool {
36 l, ok := ctx.Value(localhostKey).(bool)