Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup examples. #62

Merged
merged 1 commit into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, @dgn underscore is used for unused variables, sorry that I've missed this in the code review.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, sorry I missed this

}
}

Expand Down