We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8b21d0c commit 20c3ffdCopy full SHA for 20c3ffd
coderd/workspaceapps/cors/cors.go
@@ -0,0 +1,21 @@
1
+package cors
2
+
3
+import (
4
+ "context"
5
6
+ "github.com/coder/coder/v2/codersdk"
7
+)
8
9
+type contextKeyBehavior struct{}
10
11
+// WithBehavior sets the CORS behavior for the given context.
12
+func WithBehavior(ctx context.Context, behavior codersdk.CORSBehavior) context.Context {
13
+ return context.WithValue(ctx, contextKeyBehavior{}, behavior)
14
+}
15
16
+// HasBehavior returns true if the given context has the specified CORS behavior.
17
+func HasBehavior(ctx context.Context, behavior codersdk.CORSBehavior) bool {
18
+ val := ctx.Value(contextKeyBehavior{})
19
+ b, ok := val.(codersdk.CORSBehavior)
20
+ return ok && b == behavior
21
0 commit comments