我想獲得授權承載頭的OAuth的目的,但它看起來有點混亂讀取文檔如何獲得授權承載頭?
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")
};
這會產生錯誤:
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]
望着實現它似乎對我是正確的:
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)
}
}
https://github.com/auth0/rust-api-example/issues/1
它看起來與https://github.com/rust-lang相關/ cargo/issues/1636,通配符也是[已棄用](http://doc.crates.io/faq.html#can-libraries-use-*-as-a-version-for-their-dependencies?)和又一個[依賴 - 地獄問題](http s://en.wikipedia.org/wiki/Dependency_hell) – Marcos
@Marcos通配符依賴關係已棄用*用於發佈的庫*。二進制文件可能會使用它們,因爲它們有相應的'Cargo.lock'文件。有趣的是,這與傳統的依賴地獄問題相反。在那裏,你不能有相同箱子的衝突版本。在這裏,你可以,但如果你試圖交替使用它們,它們會發生衝突。 – Shepmaster