From e7424d1b58afa0bb28c8028b77f0afa1c4bbb9d6 Mon Sep 17 00:00:00 2001 From: Aleksandr Razumov Date: Sat, 2 Dec 2023 15:08:30 +0300 Subject: [PATCH] chore(gen): upd --- internal/lokiapi/oas_cfg_gen.go | 11 +++++++++-- internal/otelschema/_testdata/semantic-conventions | 2 +- internal/promapi/oas_cfg_gen.go | 11 +++++++++-- internal/pyroscopeapi/oas_cfg_gen.go | 11 +++++++++-- internal/sentryapi/oas_cfg_gen.go | 11 +++++++++-- internal/tempoapi/oas_cfg_gen.go | 11 +++++++++-- internal/yqlclient/ytqueryapi/oas_cfg_gen.go | 11 +++++++++-- 7 files changed, 55 insertions(+), 13 deletions(-) diff --git a/internal/lokiapi/oas_cfg_gen.go b/internal/lokiapi/oas_cfg_gen.go index ddf026ca..80ba3cee 100644 --- a/internal/lokiapi/oas_cfg_gen.go +++ b/internal/lokiapi/oas_cfg_gen.go @@ -85,8 +85,15 @@ func newServerConfig(opts ...ServerOption) serverConfig { cfg := serverConfig{ NotFound: http.NotFound, MethodNotAllowed: func(w http.ResponseWriter, r *http.Request, allowed string) { - w.Header().Set("Allow", allowed) - w.WriteHeader(http.StatusMethodNotAllowed) + status := http.StatusMethodNotAllowed + if r.Method == "OPTIONS" { + w.Header().Set("Access-Control-Allow-Methods", allowed) + w.Header().Set("Access-Control-Allow-Headers", "Content-Type") + status = http.StatusNoContent + } else { + w.Header().Set("Allow", allowed) + } + w.WriteHeader(status) }, ErrorHandler: ogenerrors.DefaultErrorHandler, Middleware: nil, diff --git a/internal/otelschema/_testdata/semantic-conventions b/internal/otelschema/_testdata/semantic-conventions index efd93451..ed7d3e0f 160000 --- a/internal/otelschema/_testdata/semantic-conventions +++ b/internal/otelschema/_testdata/semantic-conventions @@ -1 +1 @@ -Subproject commit efd9345199e986e61488def054a33f193acf7298 +Subproject commit ed7d3e0f939cbdcd6c0b6093d157d3f5e8bbc9bd diff --git a/internal/promapi/oas_cfg_gen.go b/internal/promapi/oas_cfg_gen.go index e8bcbedf..e6756b11 100644 --- a/internal/promapi/oas_cfg_gen.go +++ b/internal/promapi/oas_cfg_gen.go @@ -81,8 +81,15 @@ func newServerConfig(opts ...ServerOption) serverConfig { cfg := serverConfig{ NotFound: http.NotFound, MethodNotAllowed: func(w http.ResponseWriter, r *http.Request, allowed string) { - w.Header().Set("Allow", allowed) - w.WriteHeader(http.StatusMethodNotAllowed) + status := http.StatusMethodNotAllowed + if r.Method == "OPTIONS" { + w.Header().Set("Access-Control-Allow-Methods", allowed) + w.Header().Set("Access-Control-Allow-Headers", "Content-Type") + status = http.StatusNoContent + } else { + w.Header().Set("Allow", allowed) + } + w.WriteHeader(status) }, ErrorHandler: ogenerrors.DefaultErrorHandler, Middleware: nil, diff --git a/internal/pyroscopeapi/oas_cfg_gen.go b/internal/pyroscopeapi/oas_cfg_gen.go index 5c6ea374..ca84edc4 100644 --- a/internal/pyroscopeapi/oas_cfg_gen.go +++ b/internal/pyroscopeapi/oas_cfg_gen.go @@ -81,8 +81,15 @@ func newServerConfig(opts ...ServerOption) serverConfig { cfg := serverConfig{ NotFound: http.NotFound, MethodNotAllowed: func(w http.ResponseWriter, r *http.Request, allowed string) { - w.Header().Set("Allow", allowed) - w.WriteHeader(http.StatusMethodNotAllowed) + status := http.StatusMethodNotAllowed + if r.Method == "OPTIONS" { + w.Header().Set("Access-Control-Allow-Methods", allowed) + w.Header().Set("Access-Control-Allow-Headers", "Content-Type") + status = http.StatusNoContent + } else { + w.Header().Set("Allow", allowed) + } + w.WriteHeader(status) }, ErrorHandler: ogenerrors.DefaultErrorHandler, Middleware: nil, diff --git a/internal/sentryapi/oas_cfg_gen.go b/internal/sentryapi/oas_cfg_gen.go index a1048878..43af6b1a 100644 --- a/internal/sentryapi/oas_cfg_gen.go +++ b/internal/sentryapi/oas_cfg_gen.go @@ -87,8 +87,15 @@ func newServerConfig(opts ...ServerOption) serverConfig { cfg := serverConfig{ NotFound: http.NotFound, MethodNotAllowed: func(w http.ResponseWriter, r *http.Request, allowed string) { - w.Header().Set("Allow", allowed) - w.WriteHeader(http.StatusMethodNotAllowed) + status := http.StatusMethodNotAllowed + if r.Method == "OPTIONS" { + w.Header().Set("Access-Control-Allow-Methods", allowed) + w.Header().Set("Access-Control-Allow-Headers", "Content-Type") + status = http.StatusNoContent + } else { + w.Header().Set("Allow", allowed) + } + w.WriteHeader(status) }, ErrorHandler: ogenerrors.DefaultErrorHandler, Middleware: nil, diff --git a/internal/tempoapi/oas_cfg_gen.go b/internal/tempoapi/oas_cfg_gen.go index da06dbc2..9103986c 100644 --- a/internal/tempoapi/oas_cfg_gen.go +++ b/internal/tempoapi/oas_cfg_gen.go @@ -81,8 +81,15 @@ func newServerConfig(opts ...ServerOption) serverConfig { cfg := serverConfig{ NotFound: http.NotFound, MethodNotAllowed: func(w http.ResponseWriter, r *http.Request, allowed string) { - w.Header().Set("Allow", allowed) - w.WriteHeader(http.StatusMethodNotAllowed) + status := http.StatusMethodNotAllowed + if r.Method == "OPTIONS" { + w.Header().Set("Access-Control-Allow-Methods", allowed) + w.Header().Set("Access-Control-Allow-Headers", "Content-Type") + status = http.StatusNoContent + } else { + w.Header().Set("Allow", allowed) + } + w.WriteHeader(status) }, ErrorHandler: ogenerrors.DefaultErrorHandler, Middleware: nil, diff --git a/internal/yqlclient/ytqueryapi/oas_cfg_gen.go b/internal/yqlclient/ytqueryapi/oas_cfg_gen.go index 707c9efb..83ee6664 100644 --- a/internal/yqlclient/ytqueryapi/oas_cfg_gen.go +++ b/internal/yqlclient/ytqueryapi/oas_cfg_gen.go @@ -81,8 +81,15 @@ func newServerConfig(opts ...ServerOption) serverConfig { cfg := serverConfig{ NotFound: http.NotFound, MethodNotAllowed: func(w http.ResponseWriter, r *http.Request, allowed string) { - w.Header().Set("Allow", allowed) - w.WriteHeader(http.StatusMethodNotAllowed) + status := http.StatusMethodNotAllowed + if r.Method == "OPTIONS" { + w.Header().Set("Access-Control-Allow-Methods", allowed) + w.Header().Set("Access-Control-Allow-Headers", "Content-Type") + status = http.StatusNoContent + } else { + w.Header().Set("Allow", allowed) + } + w.WriteHeader(status) }, ErrorHandler: ogenerrors.DefaultErrorHandler, Middleware: nil,