-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Match on Option instead of using is_none
- Loading branch information
1 parent
5c145af
commit 56bac34
Showing
3 changed files
with
19 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
use tonic::{metadata::MetadataMap, Status}; | ||
|
||
pub fn raw_macaroon_from_metadata(metadata: MetadataMap) -> Result<String, Status> { | ||
let macaroon = metadata.get("macaroon"); | ||
let macaroon_opt = metadata.get("macaroon"); | ||
|
||
if macaroon.is_none() { | ||
return Err(Status::unauthenticated("macaroon is required")); | ||
match macaroon_opt { | ||
Some(macaroon) => macaroon | ||
.to_str() | ||
.map(String::from) | ||
.map_err(|_e| Status::unauthenticated("invalid macaroon: must be ascii")), | ||
None => Err(Status::unauthenticated("macaroon is required")), | ||
} | ||
|
||
macaroon | ||
.unwrap() | ||
.to_str() | ||
.map(String::from) | ||
.map_err(|_e| Status::unauthenticated("invalid macaroon: must be ascii")) | ||
} |