Skip to content

Instantly share code, notes, and snippets.

@pjenvey
Last active October 17, 2018 21:49
Show Gist options
  • Save pjenvey/57561fd4d09740055bfb034ef113ee1d to your computer and use it in GitHub Desktop.
Save pjenvey/57561fd4d09740055bfb034ef113ee1d to your computer and use it in GitHub Desktop.
diff --git a/src/web/auth.rs b/src/web/auth.rs
index 35dd410e..b625083f 100644
--- a/src/web/auth.rs
+++ b/src/web/auth.rs
@@ -59,10 +59,7 @@ impl HawkPayload {
}
let header: HawkHeader = header[5..].parse()?;
- let id = header.id.as_ref().ok_or_else(|| {
- let error: ApiError = HawkErrorKind::MissingId.into();
- error
- })?;
+ let id = header.id.as_ref().ok_or(HawkErrorKind::MissingId)?;
let payload = HawkPayload::extract_and_validate(id, secrets, expiry)?;
@@ -129,18 +126,12 @@ impl FromRequest<ServerState> for HawkPayload {
request
.headers()
.get("authorization")
- .ok_or_else(|| {
- let error: ApiError = HawkErrorKind::MissingHeader.into();
- error
- })?.to_str()?,
+ .ok_or(HawkErrorKind::MissingHeader)?.to_str()?,
request.method().as_str(),
request
.uri()
.path_and_query()
- .ok_or_else(|| {
- let error: ApiError = HawkErrorKind::MissingPath.into();
- error
- })?.as_str(),
+ .ok_or(HawkErrorKind::MissingPath)?.as_str(),
request.uri().host().unwrap_or("127.0.0.1"),
request.uri().port().unwrap_or(settings.port),
&request.state().secrets,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment