Skip to content

Commit b9ea6d0

Browse files
authored
Cleanup examples. (#62)
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
1 parent 802cab2 commit b9ea6d0

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

examples/BUILD

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,15 @@ rust_binary(
5252
"//bazel/cargo:log",
5353
],
5454
)
55+
56+
rust_binary(
57+
name = "http_config",
58+
srcs = ["http_config.rs"],
59+
crate_type = "cdylib",
60+
edition = "2018",
61+
out_binary = True,
62+
deps = [
63+
"//:proxy_wasm",
64+
"//bazel/cargo:log",
65+
],
66+
)

examples/http_body.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl RootContext for HttpBodyRoot {
3030
Some(ContextType::HttpContext)
3131
}
3232

33-
fn create_http_context(&self, _context_id: u32) -> Option<Box<dyn HttpContext>> {
33+
fn create_http_context(&self, _: u32) -> Option<Box<dyn HttpContext>> {
3434
Some(Box::new(HttpBody))
3535
}
3636
}

examples/http_config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct HttpConfigHeader {
3232
impl Context for HttpConfigHeader {}
3333

3434
impl HttpContext for HttpConfigHeader {
35-
fn on_http_response_headers(&mut self, _num_headers: usize) -> Action {
35+
fn on_http_response_headers(&mut self, _: usize) -> Action {
3636
self.add_http_response_header("custom-header", self.header_content.as_str());
3737
Action::Continue
3838
}
@@ -45,14 +45,14 @@ struct HttpConfigHeaderRoot {
4545
impl Context for HttpConfigHeaderRoot {}
4646

4747
impl RootContext for HttpConfigHeaderRoot {
48-
fn on_configure(&mut self, _plugin_configuration_size: usize) -> bool {
48+
fn on_configure(&mut self, _: usize) -> bool {
4949
if let Some(config_bytes) = self.get_configuration() {
5050
self.header_content = String::from_utf8(config_bytes).unwrap()
5151
}
5252
true
5353
}
5454

55-
fn create_http_context(&self, _context_id: u32) -> Option<Box<dyn HttpContext>> {
55+
fn create_http_context(&self, _: u32) -> Option<Box<dyn HttpContext>> {
5656
Some(Box::new(HttpConfigHeader {
5757
header_content: self.header_content.clone(),
5858
}))

examples/http_headers.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ impl RootContext for HttpHeadersRoot {
3131
Some(ContextType::HttpContext)
3232
}
3333

34-
fn create_http_context(&self, _context_id: u32) -> Option<Box<dyn HttpContext>> {
35-
Some(Box::new(HttpHeaders {
36-
context_id: _context_id,
37-
}))
34+
fn create_http_context(&self, context_id: u32) -> Option<Box<dyn HttpContext>> {
35+
Some(Box::new(HttpHeaders { context_id }))
3836
}
3937
}
4038

0 commit comments

Comments
 (0)