Documentation ¶
Overview ¶
Package browser contains internal helpers that are only used for browser requests.
Index ¶
Constants ¶
const (
// DefaultAllowedOrigin is the default origin string to use in CORS response headers.
DefaultAllowedOrigin = "*"
)
Variables ¶
var DefaultAllowedHeaders = strings.Join([]string{ "Cache-Control", "Content-Type", "Content-Length", "Accept-Encoding", "X-LaunchDarkly-User-Agent", "X-LaunchDarkly-Payload-ID", "X-LaunchDarkly-Wrapper", events.EventSchemaHeader, events.TagsHeader, }, ",")
DefaultAllowedHeaders is the default value of the CORS header Access-Control-Allow-Headers.
var Transparent1PixelImageData []byte = makePixelImageData() //nolint:gochecknoglobals
Transparent1PixelImageData is the response data for the fake-image endpoint that browsers can use to send events. It is exported for use in test code.
Functions ¶
func SetCORSHeaders ¶
func SetCORSHeaders(w http.ResponseWriter, origin string, extraAllowedHeaders []string)
SetCORSHeaders sets a standard set of CORS headers on an HTTP response. This is meant to be the same behavior that the LaunchDarkly service endpoints uses for client-side JS requests.
func WithCORSContext ¶
func WithCORSContext(parent context.Context, cc CORSContext) context.Context
WithCORSContext returns a copy of the parent context with the specified CORSContext attached.
Types ¶
type CORSContext ¶
CORSContext represents a scope that has a specific set of allowed origins for CORS requests. This can be attached to a request context with WithCORSContext().
func GetCORSContext ¶
func GetCORSContext(ctx context.Context) CORSContext
GetCORSContext returns the CORSContext that has been attached to this Context with WithCORSContext(), or nil if none.