Skip to content

Commit

Permalink
Cleanup examples. (#62)
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
  • Loading branch information
PiotrSikora authored Dec 7, 2020
1 parent 802cab2 commit b9ea6d0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
12 changes: 12 additions & 0 deletions examples/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)
2 changes: 1 addition & 1 deletion examples/http_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl RootContext for HttpBodyRoot {
Some(ContextType::HttpContext)
}

fn create_http_context(&self, _context_id: u32) -> Option<Box<dyn HttpContext>> {
fn create_http_context(&self, _: u32) -> Option<Box<dyn HttpContext>> {
Some(Box::new(HttpBody))
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/http_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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<Box<dyn HttpContext>> {
fn create_http_context(&self, _: u32) -> Option<Box<dyn HttpContext>> {
Some(Box::new(HttpConfigHeader {
header_content: self.header_content.clone(),
}))
Expand Down
6 changes: 2 additions & 4 deletions examples/http_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ impl RootContext for HttpHeadersRoot {
Some(ContextType::HttpContext)
}

fn create_http_context(&self, _context_id: u32) -> Option<Box<dyn HttpContext>> {
Some(Box::new(HttpHeaders {
context_id: _context_id,
}))
fn create_http_context(&self, context_id: u32) -> Option<Box<dyn HttpContext>> {
Some(Box::new(HttpHeaders { context_id }))
}
}

Expand Down

0 comments on commit b9ea6d0

Please sign in to comment.