Skip to content

Commit 6932af5

Browse files
jplatteseanmonstar
authored andcommitted
Add forwarding methods to Authorization<C> for provided C's
1 parent 6b065f9 commit 6932af5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/common/authorization.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ impl Authorization<Basic> {
4545

4646
Authorization(Basic { decoded, colon_pos })
4747
}
48+
49+
/// View the decoded username.
50+
pub fn username(&self) -> &str {
51+
self.0.username()
52+
}
53+
54+
/// View the decoded password.
55+
pub fn password(&self) -> &str {
56+
self.0.password()
57+
}
4858
}
4959

5060
impl Authorization<Bearer> {
@@ -54,6 +64,11 @@ impl Authorization<Bearer> {
5464
.map(|val| Authorization(Bearer(val)))
5565
.ok_or_else(|| InvalidBearerToken { _inner: () })
5666
}
67+
68+
/// View the token part as a `&str`.
69+
pub fn token(&self) -> &str {
70+
self.0.token()
71+
}
5772
}
5873

5974
impl<C: Credentials> ::Header for Authorization<C> {

0 commit comments

Comments
 (0)