iron / iron/body-parser

the trait `plugin::Plugin<iron::Request<'_, '_>>` is not implemented for `bodyparser::Raw`

Open
#81 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
53
Forks
26
PR merge metrics
No merged PRs in 30d

Description

I tried to use the example as a reference to get my own code working, but it fails with:

```rust
error[E0277]: the trait bound `bodyparser::Raw: plugin::Plugin>` is not satisfied
--> src/main.rs:27:24
|
27 | let body = req.get::();
| ^^^ the trait `plugin::Plugin>` is not implemented for `bodyparser::Raw`
|
= help: the following implementations were found:
>>
```

The code in question:

```rust
let (tx, rx) = mpsc::channel();
let sender = Mutex::new(tx);
let chain = Chain::new(move |req: &mut Request| -> IronResult {
println!("received request");

let body = req.get::();
match body {
Ok(Some(body)) => println!("Read body:\n{}", body),
Ok(None) => println!("No body"),
Err(err) => println!("Error: {:?}", err),
}

let tx = sender.lock().unwrap().clone(); //Or whatever
tx.send("request");

return Ok(Response::with((status::Ok, "Hello World")));
});
chain.link_before(Read::::one(MAX_BODY_LENGTH));

thread::spawn(move || {
for received in rx {
println!("{}", received)
}
});

match Iron::new(chain).http(env::var("BIND").unwrap()) {
Ok(_) => println!("fine"),
Err(error) => panic!("failed to bind HTTP listener: {:?}", error),
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.