Extract credentials from the headers or else query string of a request.
(parts: &request::Parts)
| 64 | |
| 65 | /// Extract credentials from the headers or else query string of a request. |
| 66 | fn from_request_parts(parts: &request::Parts) -> Result<Option<Self>, headers::Error> { |
| 67 | let header = parts |
| 68 | .headers |
| 69 | .typed_try_get::<headers::Authorization<authorization::Bearer>>()?; |
| 70 | if let Some(headers::Authorization(bearer)) = header { |
| 71 | let token = bearer.token().to_owned(); |
| 72 | return Ok(Some(SpacetimeCreds { token })); |
| 73 | } |
| 74 | if let Ok(Query(creds)) = Query::<Self>::try_from_uri(&parts.uri) { |
| 75 | return Ok(Some(creds)); |
| 76 | } |
| 77 | Ok(None) |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | /// The auth information in a request. |
nothing calls this directly
no test coverage detected