-
Notifications
You must be signed in to change notification settings - Fork 76
/
js_context.go
28 lines (22 loc) · 1.04 KB
/
js_context.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
package relayenv
import "net/http/httputil"
// JSClientContext contains additional environment properties that are only relevant if this
// environment supports JavaScript clients (i.e. we know its environment ID).
type JSClientContext struct {
// Origins is the configured list of allowed origins for CORS requests.
Origins []string
// Headers is the configured list of allowed headers for CORS requests.
Headers []string
// Proxy is a ReverseProxy that we create for requests that are to be directly proxied to a
// LaunchDarkly endpoint. Despite its name, the Relay Proxy does not normally use direct
// proxying, but in the case of the goals resource for JS clients it is the simplest way.
Proxy *httputil.ReverseProxy
}
// AllowedOrigins implements the internal interface for getting CORS allowed origins.
func (c JSClientContext) AllowedOrigins() []string {
return c.Origins
}
// AllowedHeaders implements the internal interface for getting additional CORS allowed headers.
func (c JSClientContext) AllowedHeaders() []string {
return c.Headers
}