diff --git a/changelog.d/21173_http_server_options_support.feature.md b/changelog.d/21173_http_server_options_support.feature.md new file mode 100644 index 0000000000000..2031bc386e313 --- /dev/null +++ b/changelog.d/21173_http_server_options_support.feature.md @@ -0,0 +1,3 @@ +Adds support `OPTIONS` HTTP-method for http_server source + +authors: sillent diff --git a/src/sources/util/http/method.rs b/src/sources/util/http/method.rs index a816dc42f7cdc..c090ce3dce867 100644 --- a/src/sources/util/http/method.rs +++ b/src/sources/util/http/method.rs @@ -23,6 +23,9 @@ pub enum HttpMethod { /// HTTP DELETE method. Delete, + + /// HTTP OPTIONS method. + Options, } impl From for Method { @@ -34,6 +37,7 @@ impl From for Method { HttpMethod::Put => Self::PUT, HttpMethod::Patch => Self::PATCH, HttpMethod::Delete => Self::DELETE, + HttpMethod::Options => Self::OPTIONS, } } } diff --git a/src/sources/util/http/prelude.rs b/src/sources/util/http/prelude.rs index 5346f14f519db..cb054937fdc9c 100644 --- a/src/sources/util/http/prelude.rs +++ b/src/sources/util/http/prelude.rs @@ -99,6 +99,7 @@ pub trait HttpSource: Clone + Send + Sync + 'static { HttpMethod::Post => warp::post().boxed(), HttpMethod::Patch => warp::patch().boxed(), HttpMethod::Delete => warp::delete().boxed(), + HttpMethod::Options => warp::options().boxed(), }; // https://github.com/rust-lang/rust-clippy/issues/8148 diff --git a/src/sources/util/http_client.rs b/src/sources/util/http_client.rs index c11ac7fa83452..fd5ffb1b03260 100644 --- a/src/sources/util/http_client.rs +++ b/src/sources/util/http_client.rs @@ -154,6 +154,7 @@ pub(crate) async fn call< HttpMethod::Put => Request::put(&url), HttpMethod::Patch => Request::patch(&url), HttpMethod::Delete => Request::delete(&url), + HttpMethod::Options => Request::options(&url), }; // add user specified headers diff --git a/website/cue/reference/components/sources/base/http.cue b/website/cue/reference/components/sources/base/http.cue index dc02088bd56c2..1691c853faaf1 100644 --- a/website/cue/reference/components/sources/base/http.cue +++ b/website/cue/reference/components/sources/base/http.cue @@ -477,12 +477,13 @@ base: components: sources: http: configuration: { type: string: { default: "POST" enum: { - DELETE: "HTTP DELETE method." - GET: "HTTP GET method." - HEAD: "HTTP HEAD method." - PATCH: "HTTP PATCH method." - POST: "HTTP POST method." - PUT: "HTTP Put method." + DELETE: "HTTP DELETE method." + GET: "HTTP GET method." + HEAD: "HTTP HEAD method." + OPTIONS: "HTTP OPTIONS method." + PATCH: "HTTP PATCH method." + POST: "HTTP POST method." + PUT: "HTTP Put method." } } } diff --git a/website/cue/reference/components/sources/base/http_client.cue b/website/cue/reference/components/sources/base/http_client.cue index dbe7cc3761874..ca9742e9686c8 100644 --- a/website/cue/reference/components/sources/base/http_client.cue +++ b/website/cue/reference/components/sources/base/http_client.cue @@ -429,12 +429,13 @@ base: components: sources: http_client: configuration: { type: string: { default: "GET" enum: { - DELETE: "HTTP DELETE method." - GET: "HTTP GET method." - HEAD: "HTTP HEAD method." - PATCH: "HTTP PATCH method." - POST: "HTTP POST method." - PUT: "HTTP Put method." + DELETE: "HTTP DELETE method." + GET: "HTTP GET method." + HEAD: "HTTP HEAD method." + OPTIONS: "HTTP OPTIONS method." + PATCH: "HTTP PATCH method." + POST: "HTTP POST method." + PUT: "HTTP Put method." } } } diff --git a/website/cue/reference/components/sources/base/http_server.cue b/website/cue/reference/components/sources/base/http_server.cue index cb28b7e22c8a7..64387468f7b87 100644 --- a/website/cue/reference/components/sources/base/http_server.cue +++ b/website/cue/reference/components/sources/base/http_server.cue @@ -477,12 +477,13 @@ base: components: sources: http_server: configuration: { type: string: { default: "POST" enum: { - DELETE: "HTTP DELETE method." - GET: "HTTP GET method." - HEAD: "HTTP HEAD method." - PATCH: "HTTP PATCH method." - POST: "HTTP POST method." - PUT: "HTTP Put method." + DELETE: "HTTP DELETE method." + GET: "HTTP GET method." + HEAD: "HTTP HEAD method." + OPTIONS: "HTTP OPTIONS method." + PATCH: "HTTP PATCH method." + POST: "HTTP POST method." + PUT: "HTTP Put method." } } }