bug in example enable_cors.rs
dominuskernel opened this issue · comments
In this code:
fn enable_cors<'mw>(_req: &mut Request, mut res: Response<'mw>) -> MiddlewareResult<'mw> {
res.set(AccessControlAllowOrigin::Any);
res.set(AccessControlAllowHeaders(vec![
"Origin".into(),
"X-Requested-With".into(),
"Content-Type".into(),
"Accept".into(),
]));
res.next_middleware()
}
I get this error:
the trait `modifier::Modifier<nickel::response::Response<'_>>` is not implemented for the type `hyper::header::common::access_control_all
ow_origin::AccessControlAllowOrigin` [E0277]
src/main.rs:8 res.set(AccessControlAllowOrigin::Any);
You tried to use a type which doesn't implement some trait in a place which
expected that trait.
And it is exactly as the example.
Maybe this example is wrong.
This is likely due to having hyper = "*"
in your Cargo.toml, while nickel
was previously using 0.6. You should be able to fix it by changing to hyper = "0.6"
, or by upgrading nickel to the newly published 0.8. You might need a cargo update
to get things working.
You right. Thank you.
Alright :) I will close this, feel free to let us know about any future issues!