MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / bearer_token

Function bearer_token

mserver/MasterService/src/http.rs:864–885  ·  view source on GitHub ↗

The server token from `Authorization: Bearer ` (or the `x-server-token` header).

(headers: &HeaderMap)

Source from the content-addressed store, hash-verified

862 .map(str::trim)
863 .filter(|value| !value.is_empty())
864 .unwrap_or("http");
865 Some(format!("{scheme}://{host}"))
866}
867
868/// Rewrite a server-relative `download_url` (`/v1/mods/<id>/download`) to an absolute URL
869/// against `base`, so clients (libcurl) get a usable URL. An already-absolute URL (a CDN
870/// link) and `None` are left untouched, and the stored manifest stays host-portable.
871fn absolutize_download_url(url: &mut Option<String>, base: Option<&str>) {
872 let (Some(current), Some(base)) = (url.as_deref(), base) else {
873 return;
874 };
875 if current.is_empty() || current.contains("://") {
876 return;
877 }
878 let base = base.trim_end_matches('/');
879 let path = if current.starts_with('/') {
880 current.to_string()
881 } else {
882 format!("/{current}")
883 };
884 *url = Some(format!("{base}{path}"));
885}
886
887fn forwarded_ips(state: &AppState, headers: &HeaderMap) -> Option<Vec<String>> {
888 let header = state.client_ip_header.as_ref()?;

Callers 2

register_serverFunction · 0.85
unregister_serverFunction · 0.85

Calls 3

okMethod · 0.80
strip_prefixMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected