I would like to get the Authorization Bearer header for OAuth purposes, but it looks a bit confusing reading the docs
use nickel::{Nickel, JsonBody, HttpRouter, Request, Response, MiddlewareResult, MediaType};
// Get the full Authorization header from the incoming request headers
let auth_header = match request.origin.headers.get::<Authorization<Bearer>>() {
Some(header) => header,
None => panic!("No authorization header found")
};
This generates the error:
src/main.rs:84:56: 84:86 error: the trait
hyper::header::HeaderFormat
is not implemented for the typehyper::header::common::authorization::Authorization<hyper::header::common::authorization::Bearer>
[E0277]
Looking at implementation it appears for me to be correct:
https://github.com/hyperium/hyper/blob/master/src/header/common/authorization.rs
impl<S: Scheme + Any> HeaderFormat for Authorization<S> where <S as FromStr>::Err: 'static {
fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let Some(scheme) = <S as Scheme>::scheme() {
try!(write!(f, "{} ", scheme))
};
self.0.fmt_scheme(f)
}
}