@@ -72,18 +72,15 @@ pub trait Context {
7272 ///
7373 /// # Returns
7474 ///
75- /// * `OK` on success.
76- /// * `BAD_ARGUMENT` for unknown upstream, or when headers are missing required `:authority`, `:method` and/or `:path` values.
77- /// * `INTERNAL_FAILURE' when the host failed to send requested HTTP call.
78- /// * `INVALID_MEMORY_ACCESS` when `upstream_data`, `upstream_size`, `headers_data`, `headers_size`, `body_data`, `body_size`, `trailers_data`, `trailers_size` and/or `return_call_id` point to invalid memory address.
75+ /// A Result containing the token id of the request, or an error status.
7976 ///
8077 /// # Example
8178 ///
8279 /// ```rust
8380 /// use proxy_wasm::traits::*;
8481 /// use proxy_wasm::types::*;
8582 /// use std::time::Duration;
86- /// use log::warn;
83+ /// use log::{debug, warn} ;
8784 ///
8885 /// struct MyPlugin;
8986 ///
@@ -113,7 +110,7 @@ pub trait Context {
113110 /// let headers = self.get_http_call_response_headers();
114111 /// let body = self.get_http_call_response_body(0, body_size);
115112 ///
116- /// info !("Received response headers: {:?}", headers);
113+ /// debug !("Received response headers: {:?}", headers);
117114 ///
118115 /// // Do something with the response
119116 /// }
@@ -130,13 +127,13 @@ pub trait Context {
130127 hostcalls:: dispatch_http_call ( upstream, headers, body, trailers, timeout)
131128 }
132129
133- /// Called when HTTP response for call_id sent using proxy_http_call is received.
130+ /// Called when HTTP response using `dispatch_http_call` is received.
134131 ///
135132 /// If `num_headers` is 0, then the HTTP call failed.
136133 ///
137- /// All `num_headers` headers can be retrieved using `self.get_http_response_headers()` or individually `self.get_http_response_header()`.
134+ /// All headers can be retrieved using `self.get_http_response_headers()` or individually `self.get_http_response_header(name )`.
138135 ///
139- /// All `num_trailers` trailers can be retrieved using `self.get_http_response_trailers()` or individually `self.get_http_response_trailer()`.
136+ /// All trailers can be retrieved using `self.get_http_response_trailers()` or individually `self.get_http_response_trailer(name )`.
140137 ///
141138 /// # Arguments
142139 ///
@@ -350,7 +347,6 @@ pub trait RootContext: Context {
350347 /// ```rust
351348 /// use proxy_wasm::traits::*;
352349 /// use proxy_wasm::types::*;
353- /// use serde_json;
354350 /// use log::debug;
355351 ///
356352 /// struct MyRootContext;
@@ -365,7 +361,8 @@ pub trait RootContext: Context {
365361 /// fn on_vm_start(&mut self, _vm_configuration_size: usize) -> bool {
366362 /// let vm_configuration = self.get_vm_configuration().unwrap();
367363 ///
368- /// let parsed_vm_configuration: MyVmConfiguration = serde_json::from_slice::<MyVmConfiguration>(&vm_configuration).unwrap();
364+ /// let parsed_vm_configuration: MyVmConfiguration =
365+ /// serde_json::from_slice::<MyVmConfiguration>(&vm_configuration).unwrap();
369366 ///
370367 /// // Do something with the parsed vm configuration
371368 /// debug!("vm_configuration: {:?}", parsed_vm_configuration)
@@ -389,7 +386,6 @@ pub trait RootContext: Context {
389386 /// ```rust
390387 /// use proxy_wasm::traits::*;
391388 /// use proxy_wasm::types::*;
392- /// use serde_json;
393389 /// use log::debug;
394390 ///
395391 /// struct MyRootContext;
@@ -404,7 +400,8 @@ pub trait RootContext: Context {
404400 /// fn on_vm_start(&mut self, _vm_configuration_size: usize) -> bool {
405401 /// let vm_configuration = self.get_vm_configuration().unwrap();
406402 ///
407- /// let parsed_vm_configuration: MyVmConfiguration = serde_json::from_slice::<MyVmConfiguration>(&vm_configuration).unwrap();
403+ /// let parsed_vm_configuration: MyVmConfiguration =
404+ /// serde_json::from_slice::<MyVmConfiguration>(&vm_configuration).unwrap();
408405 ///
409406 /// // Do something with the parsed vm configuration
410407 /// debug!("vm_configuration: {:?}", parsed_vm_configuration)
@@ -433,7 +430,6 @@ pub trait RootContext: Context {
433430 /// ```rust
434431 /// use proxy_wasm::traits::*;
435432 /// use proxy_wasm::types::*;
436- /// use serde_json;
437433 /// use log::debug;
438434 ///
439435 /// struct MyRootContext;
@@ -448,7 +444,8 @@ pub trait RootContext: Context {
448444 /// fn on_configure(&mut self, _plugin_configuration_size: usize) -> bool {
449445 /// let plugin_configuration = self.get_plugin_configuration().unwrap();
450446 ///
451- /// let parsed_plugin_configuration: MyPluginConfiguration = serde_json::from_slice::<MyPluginConfiguration>(&plugin_configuration).unwrap();
447+ /// let parsed_plugin_configuration: MyPluginConfiguration =
448+ /// serde_json::from_slice::<MyPluginConfiguration>(&plugin_configuration).unwrap();
452449 ///
453450 /// // Do something with the parsed plugin configuration
454451 /// debug!("plugin_configuration: {:?}", parsed_plugin_configuration)
@@ -472,7 +469,6 @@ pub trait RootContext: Context {
472469 /// ```rust
473470 /// use proxy_wasm::traits::*;
474471 /// use proxy_wasm::types::*;
475- /// use serde_json;
476472 /// use log::debug;
477473 ///
478474 /// struct MyRootContext;
@@ -487,7 +483,8 @@ pub trait RootContext: Context {
487483 /// fn on_configure(&mut self, _plugin_configuration_size: usize) -> bool {
488484 /// let plugin_configuration = self.get_plugin_configuration().unwrap();
489485 ///
490- /// let parsed_plugin_configuration: MyPluginConfiguration = serde_json::from_slice::<MyPluginConfiguration>(&plugin_configuration).unwrap();
486+ /// let parsed_plugin_configuration: MyPluginConfiguration =
487+ /// serde_json::from_slice::<MyPluginConfiguration>(&plugin_configuration).unwrap();
491488 ///
492489 /// // Do something with the parsed plugin configuration
493490 /// debug!("plugin_configuration: {:?}", parsed_plugin_configuration)
@@ -640,7 +637,7 @@ pub trait HttpContext: Context {
640637 ///
641638 /// Paused request can be resumed using `self.resume_http_request()` or closed using `self.reset_http_request()`.
642639 ///
643- /// Additionally, instead of forwarding request upstream, a HTTP response can be sent using `self.send_http_response()`.
640+ /// Additionally, instead of forwarding requests upstream, a HTTP response can be sent using `self.send_http_response()`.
644641 ///
645642 /// # Arguments
646643 ///
@@ -722,7 +719,7 @@ pub trait HttpContext: Context {
722719 hostcalls:: set_map_bytes ( MapType :: HttpRequestHeaders , headers) . unwrap ( )
723720 }
724721
725- /// Get a specific HTTP request header.
722+ /// Get a specific HTTP request header by name .
726723 ///
727724 /// # Arguments
728725 ///
@@ -973,9 +970,9 @@ pub trait HttpContext: Context {
973970 hostcalls:: reset_http_response ( ) . unwrap ( )
974971 }
975972
976- /// Sends an HTTP response with the body and serialized headers.
973+ /// Sends an HTTP response with the specified status code, headers, and body .
977974 ///
978- /// This can be used as long as HTTP response headers were not sent downstream.
975+ /// This can be used as long as HTTP response headers were not sent downstream yet .
979976 ///
980977 /// # Arguments
981978 ///
@@ -1000,7 +997,7 @@ pub trait HttpContext: Context {
1000997 /// // Send an HTTP response with a status code of 200 and a body of "Hello, World!"
1001998 /// self.send_http_response(200, vec![("A header", "Some Value")], Some(b"Hello, World!"));
1002999 /// } else {
1003- /// // Send an HTTP response with a status code of 403 and a body of "Forbidden"
1000+ /// // Send an HTTP response with a status code of 307, redirecting to authenticate-here.com, and a body of "Forbidden"
10041001 /// self.send_http_response(307, vec![("location", "https://authenticate-here.com")], Some(b"Forbidden"));
10051002 /// }
10061003 ///
0 commit comments