MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / bearer_or_header_token

Function bearer_or_header_token

packages/server/src/auth.rs:179–193  ·  view source on GitHub ↗
(headers: &HeaderMap)

Source from the content-addressed store, hash-verified

177}
178
179fn bearer_or_header_token(headers: &HeaderMap) -> Option<&str> {
180 headers
181 .get(ACCESS_TOKEN_HEADER)
182 .and_then(|value| value.to_str().ok())
183 .map(str::trim)
184 .filter(|value| !value.is_empty())
185 .or_else(|| {
186 headers
187 .get(header::AUTHORIZATION)
188 .and_then(|value| value.to_str().ok())
189 .and_then(|value| value.trim().strip_prefix("Bearer "))
190 .map(str::trim)
191 .filter(|value| !value.is_empty())
192 })
193}
194
195fn cookie_token(headers: &HeaderMap) -> Option<&str> {
196 let cookie = headers.get(header::COOKIE)?.to_str().ok()?;

Callers 1

api_request_authorizedFunction · 0.85

Calls 2

is_emptyMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected