Skip to content

Commit

Permalink
http (server,client) OPTIONS method added (#21173)
Browse files Browse the repository at this point in the history
* http (server,client) OPTIONS method added

* Update website/cue/reference/components/sources/base/http.cue

Co-authored-by: Bryce Eadie <[email protected]>

* Update website/cue/reference/components/sources/base/http_client.cue

Co-authored-by: Bryce Eadie <[email protected]>

* Update website/cue/reference/components/sources/base/http_server.cue

Co-authored-by: Bryce Eadie <[email protected]>

* adds changelog

* fix component docs

---------

Co-authored-by: Bryce Eadie <[email protected]>
  • Loading branch information
sillent and buraizu authored Sep 26, 2024
1 parent f5c9555 commit 65e7167
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 18 deletions.
3 changes: 3 additions & 0 deletions changelog.d/21173_http_server_options_support.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Adds support `OPTIONS` HTTP-method for http_server source

authors: sillent
4 changes: 4 additions & 0 deletions src/sources/util/http/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ pub enum HttpMethod {

/// HTTP DELETE method.
Delete,

/// HTTP OPTIONS method.
Options,
}

impl From<HttpMethod> for Method {
Expand All @@ -34,6 +37,7 @@ impl From<HttpMethod> for Method {
HttpMethod::Put => Self::PUT,
HttpMethod::Patch => Self::PATCH,
HttpMethod::Delete => Self::DELETE,
HttpMethod::Options => Self::OPTIONS,
}
}
}
1 change: 1 addition & 0 deletions src/sources/util/http/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/sources/util/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions website/cue/reference/components/sources/base/http.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
}
Expand Down
13 changes: 7 additions & 6 deletions website/cue/reference/components/sources/base/http_client.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
}
Expand Down
13 changes: 7 additions & 6 deletions website/cue/reference/components/sources/base/http_server.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
}
Expand Down

0 comments on commit 65e7167

Please sign in to comment.