MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / org_base_url

Method org_base_url

atomic-config/src/lib.rs:151–173  ·  view source on GitHub ↗

Build the org-scoped base URL. Given `url = "https://atomic.storage"` and `org = "alice"`, returns `"https://alice.atomic.storage"`. Given `url = "http://localhost:8080"` and `org = "alice"`, returns `"http://alice.localhost:8080"`. For single-tenant servers the org is already implied by the server itself, so the URL is returned unchanged (no `{org}.` prefix).

(&self, org_slug: &str)

Source from the content-addressed store, hash-verified

149 /// For single-tenant servers the org is already implied by the server
150 /// itself, so the URL is returned unchanged (no `{org}.` prefix).
151 pub fn org_base_url(&self, org_slug: &str) -> Option<String> {
152 let url = self.url.as_ref()?;
153
154 // Single-tenant: the bare host is already tenant-scoped server-side;
155 // prefixing would produce bogus hosts like `org.org.org.example.com`.
156 if self.single_tenant {
157 return Some(url.trim_end_matches('/').to_string());
158 }
159
160 // Parse the URL to extract scheme, host, port
161 let url_parsed = url::Url::parse(url).ok()?;
162 let scheme = url_parsed.scheme();
163 let host = url_parsed.host_str()?;
164 let port = url_parsed.port();
165
166 let base = if let Some(port) = port {
167 format!("{}://{}.{}:{}", scheme, org_slug, host, port)
168 } else {
169 format!("{}://{}.{}", scheme, org_slug, host)
170 };
171
172 Some(base)
173 }
174
175 /// Get the org-scoped base URL using the default org.
176 pub fn default_org_base_url(&self) -> Option<String> {

Callers 2

build_client_with_orgFunction · 0.80
default_org_base_urlMethod · 0.80

Calls 2

as_refMethod · 0.80
parseFunction · 0.50

Tested by

no test coverage detected