Skip to content

Commit 9756371

Browse files
committed
rustfmt
Signed-off-by: Daniel Grimm <[email protected]>
1 parent 5f0302c commit 9756371

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

examples/http_config.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,27 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use std::str;
1615
use proxy_wasm::traits::*;
1716
use proxy_wasm::types::*;
17+
use std::str;
1818

1919
#[no_mangle]
2020
pub fn _start() {
2121
proxy_wasm::set_log_level(LogLevel::Trace);
2222
proxy_wasm::set_root_context(|_| -> Box<dyn RootContext> {
23-
Box::new(HttpConfigHeaderRootContext{
23+
Box::new(HttpConfigHeaderRootContext {
2424
header_content: "".to_string(),
2525
})
2626
});
2727
}
2828

29-
struct HttpConfigHeader{
30-
header_content: String
29+
struct HttpConfigHeader {
30+
header_content: String,
3131
}
3232

3333
impl Context for HttpConfigHeader {}
3434

3535
impl HttpContext for HttpConfigHeader {
36-
3736
fn on_http_response_headers(&mut self, _num_headers: usize) -> Action {
3837
self.add_http_response_header("custom-header", self.header_content.as_str());
3938

@@ -42,13 +41,12 @@ impl HttpContext for HttpConfigHeader {
4241
}
4342

4443
struct HttpConfigHeaderRootContext {
45-
header_content: String
44+
header_content: String,
4645
}
4746

4847
impl Context for HttpConfigHeaderRootContext {}
4948

5049
impl RootContext for HttpConfigHeaderRootContext {
51-
5250
fn on_configure(&mut self, _plugin_configuration_size: usize) -> bool {
5351
if let Some(config_bytes) = self.get_configuration() {
5452
self.header_content = str::from_utf8(config_bytes.as_ref()).unwrap().to_owned()
@@ -57,13 +55,12 @@ impl RootContext for HttpConfigHeaderRootContext {
5755
}
5856

5957
fn create_http_context(&self, _context_id: u32) -> Option<Box<dyn HttpContext>> {
60-
Some(Box::new(HttpConfigHeader{
58+
Some(Box::new(HttpConfigHeader {
6159
header_content: self.header_content.clone(),
6260
}))
6361
}
6462

6563
fn get_type(&self) -> Option<ContextType> {
6664
Some(ContextType::HttpContext)
6765
}
68-
6966
}

src/dispatcher.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,12 @@ impl Dispatcher {
157157
self.create_stream_context(context_id, root_context_id);
158158
} else if let Some(root_context) = self.roots.borrow().get(&root_context_id) {
159159
match root_context.get_type() {
160-
Some(ContextType::HttpContext) => self.create_http_context(context_id, root_context_id),
161-
Some(ContextType::StreamContext) => self.create_stream_context(context_id, root_context_id),
160+
Some(ContextType::HttpContext) => {
161+
self.create_http_context(context_id, root_context_id)
162+
}
163+
Some(ContextType::StreamContext) => {
164+
self.create_stream_context(context_id, root_context_id)
165+
}
162166
None => panic!("missing ContextType on root_context"),
163167
}
164168
} else {

0 commit comments

Comments
 (0)