Skip to content

Commit 60d9295

Browse files
author
Younes
committed
Update hostcalls.rs
Signed-off-by: Younes <[email protected]>
1 parent c16ace3 commit 60d9295

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

src/hostcalls.rs

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -749,39 +749,36 @@ extern "C" {
749749
///
750750
/// # Arguments
751751
///
752-
/// * `upstream`: The URL or host of the upstream server to which the HTTP call will be made.
753-
/// * `headers`: A vector of tuples representing the HTTP headers to include in the request.
754-
/// Each tuple consists of a header name and value.
755-
/// * `body`: An optional byte slice representing the request body.
756-
/// * `trailers`: An optional vector of tuples representing the HTTP trailers to include in
757-
/// the request. Each tuple consists of a trailer name and value.
758-
/// * `timeout`: The duration after which the HTTP call will time out if no response is received.
752+
/// * `upstream`: A string specifying the name of the upstream cluster to send the HTTP request to.
753+
/// * `headers`: A vector of tuples representing the HTTP headers to include in the request. Each tuple contains a header name and its corresponding value.
754+
/// * `body`: An optional byte slice representing the body of the HTTP request.
755+
/// * `trailers`: A vector of tuples representing the trailers to include in the request. Each tuple contains a trailer name and its corresponding value.
756+
/// * `timeout`: A `Duration` specifying the timeout duration for the HTTP request.
759757
///
760758
/// # Returns
761759
///
762-
/// A `Result` indicating the success or failure of the HTTP call. If the call is successful,
763-
/// the function returns an HTTP status code as a `u32`. If an error occurs, an `Error` object
764-
/// is returned.
760+
/// A `Result` indicating the success or failure of the HTTP call. If the call is successful, the function returns an HTTP status code as a `u32`. If an error occurs, an `Error` object is returned.
765761
///
766762
/// # Example
767763
///
768764
/// ```rust
769765
/// use proxy_wasm::hostcalls::dispatch_http_call;
766+
/// use std::time::Duration;
770767
///
771-
/// let upstream = "http://example.com";
772-
/// let headers = vec![("Content-Type", "application/json")];
773-
/// let body = Some(b"request body");
774-
/// let trailers = Some(vec![("Trailer-Name", "trailer value")]);
775-
/// let timeout = std::time::Duration::from_secs(5);
768+
/// fn main() {
769+
/// let upstream = "my_upstream";
770+
/// let headers = vec![("Content-Type", "application/json")];
771+
/// let body = Some(b"request body");
772+
/// let trailers = vec![];
773+
/// let timeout = Duration::from_secs(5);
776774
///
777-
/// let result = dispatch_http_call(upstream, headers, body, trailers, timeout);
778-
///
779-
/// match result {
780-
/// Ok(status_code) => {
781-
/// println!("HTTP call successful. Status code: {}", status_code);
782-
/// }
783-
/// Err(error) => {
784-
/// println!("HTTP call failed. Error: {:?}", error);
775+
/// match dispatch_http_call(upstream, headers, body, trailers, timeout) {
776+
/// Ok(return_token) => {
777+
/// println!("HTTP call dispatched successfully. Return token: {}", return_token);
778+
/// }
779+
/// Err(status) => {
780+
/// println!("Failed to dispatch HTTP call. Error status: {:?}", status);
781+
/// }
785782
/// }
786783
/// }
787784
/// ```

0 commit comments

Comments
 (0)