From 6a9ba07aa4285c86e866d5c5d7ff3908d3954fbc Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Mon, 7 Dec 2020 01:54:16 +0000 Subject: [PATCH] Cleanup examples. Signed-off-by: Piotr Sikora --- examples/BUILD | 12 ++++++++++++ examples/http_body.rs | 2 +- examples/http_config.rs | 6 +++--- examples/http_headers.rs | 6 ++---- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/examples/BUILD b/examples/BUILD index 047cae40..ba5935dd 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -52,3 +52,15 @@ rust_binary( "//bazel/cargo:log", ], ) + +rust_binary( + name = "http_config", + srcs = ["http_config.rs"], + crate_type = "cdylib", + edition = "2018", + out_binary = True, + deps = [ + "//:proxy_wasm", + "//bazel/cargo:log", + ], +) diff --git a/examples/http_body.rs b/examples/http_body.rs index 374a8751..ff884648 100644 --- a/examples/http_body.rs +++ b/examples/http_body.rs @@ -30,7 +30,7 @@ impl RootContext for HttpBodyRoot { Some(ContextType::HttpContext) } - fn create_http_context(&self, _context_id: u32) -> Option> { + fn create_http_context(&self, _: u32) -> Option> { Some(Box::new(HttpBody)) } } diff --git a/examples/http_config.rs b/examples/http_config.rs index fc297a08..d912ae03 100644 --- a/examples/http_config.rs +++ b/examples/http_config.rs @@ -32,7 +32,7 @@ struct HttpConfigHeader { impl Context for HttpConfigHeader {} impl HttpContext for HttpConfigHeader { - fn on_http_response_headers(&mut self, _num_headers: usize) -> Action { + fn on_http_response_headers(&mut self, _: usize) -> Action { self.add_http_response_header("custom-header", self.header_content.as_str()); Action::Continue } @@ -45,14 +45,14 @@ struct HttpConfigHeaderRoot { impl Context for HttpConfigHeaderRoot {} impl RootContext for HttpConfigHeaderRoot { - fn on_configure(&mut self, _plugin_configuration_size: usize) -> bool { + fn on_configure(&mut self, _: usize) -> bool { if let Some(config_bytes) = self.get_configuration() { self.header_content = String::from_utf8(config_bytes).unwrap() } true } - fn create_http_context(&self, _context_id: u32) -> Option> { + fn create_http_context(&self, _: u32) -> Option> { Some(Box::new(HttpConfigHeader { header_content: self.header_content.clone(), })) diff --git a/examples/http_headers.rs b/examples/http_headers.rs index 615fdcc6..b0f1a745 100644 --- a/examples/http_headers.rs +++ b/examples/http_headers.rs @@ -31,10 +31,8 @@ impl RootContext for HttpHeadersRoot { Some(ContextType::HttpContext) } - fn create_http_context(&self, _context_id: u32) -> Option> { - Some(Box::new(HttpHeaders { - context_id: _context_id, - })) + fn create_http_context(&self, context_id: u32) -> Option> { + Some(Box::new(HttpHeaders { context_id })) } }