Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/public-api-server/pkg/origin/context.go
2500 views
1
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package origin
6
7
import (
8
"context"
9
)
10
11
type contextKey int
12
13
const (
14
originContextKey contextKey = iota
15
)
16
17
func ToContext(ctx context.Context, origin string) context.Context {
18
return context.WithValue(ctx, originContextKey, origin)
19
}
20
21
func FromContext(ctx context.Context) string {
22
if val, ok := ctx.Value(originContextKey).(string); ok {
23
return val
24
}
25
26
return ""
27
}
28
29