MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / from_request_parts

Method from_request_parts

crates/client-api/src/auth.rs:66–78  ·  view source on GitHub ↗

Extract credentials from the headers or else query string of a request.

(parts: &request::Parts)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 8

OtherClass · 0.85
tokenMethod · 0.80
validate_tokenFunction · 0.70
OkFunction · 0.50
to_ownedMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected