Skip to content

Commit

Permalink
[confighttp] Add NewDefaultCORSConfig function to initialize the de…
Browse files Browse the repository at this point in the history
…fault `confighttp.CORSConfig`
  • Loading branch information
atoulme committed Jul 20, 2024
1 parent 7d5b1ba commit 7971e20
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .chloggen/new_cors_default_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: confighttp

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add `NewDefaultCORSConfig` function to initialize the default `confighttp.CORSConfig`

# One or more tracking issues or pull requests related to the change
issues: [9655]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api]
5 changes: 5 additions & 0 deletions config/confighttp/confighttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,11 @@ type CORSConfig struct {
MaxAge int `mapstructure:"max_age"`
}

// NewDefaultCORSConfig creates a default cross-origin resource sharing (CORS) configuration.
func NewDefaultCORSConfig() *CORSConfig {
return &CORSConfig{}
}

func authInterceptor(next http.Handler, server auth.Server, requestParams []string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
sources := r.Header
Expand Down
2 changes: 1 addition & 1 deletion config/confighttp/confighttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ func TestHttpCors(t *testing.T) {
},
{
name: "emptyCORS",
CORSConfig: &CORSConfig{},
CORSConfig: NewDefaultCORSConfig(),
allowedWorks: false,
disallowedWorks: false,
extraHeaderWorks: false,
Expand Down

0 comments on commit 7971e20

Please sign in to comment.