Trait bound `MethodRouter<B> Error #835
Answered
by
davidpdrsn
SamuelBonilla
asked this question in
Q&A
-
Hi, I'm trying to use the Router struct inside another struct but I'm getting this error on this line: self.router = self.router.route(_path, get(handler)); the trait bound 'MethodRouter: Service<hyper::Requesthyper::Body>' is not satisfied this is the code: struct MyStruc {
router: Router<Body>,
}
impl MyStruc {
pub fn new() -> Self {
Self {
router: Router::new(),
}
}
pub fn myFunc<H, T, B>(&self, _path: &path::Path<&str>, handler: H)
where
H: Handler<T, B>,
B: Send + 'static,
T: 'static,
{
self.router = self.router.route(_path, get(handler));
}
} what I'm doing wrong? |
Beta Was this translation helpful? Give feedback.
Answered by
davidpdrsn
Mar 5, 2022
Replies: 1 comment 1 reply
-
You're |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
davidpdrsn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're
Router
requiresBody
but the handler takes a genericB
. You have to either useHandler<T, Body>
orRouter<B>
. I'd recommend the former.