You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/hostcalls.rs
+20-23Lines changed: 20 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -749,39 +749,36 @@ extern "C" {
749
749
///
750
750
/// # Arguments
751
751
///
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.
759
757
///
760
758
/// # Returns
761
759
///
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.
765
761
///
766
762
/// # Example
767
763
///
768
764
/// ```rust
769
765
/// use proxy_wasm::hostcalls::dispatch_http_call;
766
+
/// use std::time::Duration;
770
767
///
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);
776
774
///
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);
0 commit comments