pub struct Venture {
pub name: String,
pub domain: String,
pub public_url: String,
pub cors_origins: Vec<String>,
pub env: VentureEnv,
pub brand: Brand,
pub problem_base: Option<String>,
}Expand description
Identity and CORS configuration for the venture this harness serves.
use cratefield_core::Venture;
let v = Venture::new("factory0", "factory0.ventures")
.public_url("https://factory0.ventures")
.cors_origins(["https://factory0.ventures"]);
assert_eq!(v.name, "factory0");
assert_eq!(v.problem_type_base(), "https://factory0.ventures/problems/");Fields§
§name: StringKebab-case venture name (factory0).
domain: StringApex domain (factory0.ventures); the API serves api.<domain>.
public_url: StringAbsolute public URL the API is linked from.
cors_origins: Vec<String>CORS allowlist. Never * (architecture section 6).
env: VentureEnvDeployment environment.
brand: BrandMail branding (issue #12).
problem_base: Option<String>Explicit Venture::problem_type_base override, for a venture that
serves its problems from somewhere other than <public_url>/problems/.
Implementations§
Source§impl Venture
impl Venture
pub fn new(name: impl Into<String>, domain: impl Into<String>) -> Self
pub fn public_url(self, url: impl Into<String>) -> Self
Sourcepub fn problem_base(self, url: impl Into<String>) -> Self
pub fn problem_base(self, url: impl Into<String>) -> Self
Overrides the base every problem type of this venture is served
under (RFC 9457): the full base URI, ending in /. Unset, the base
derives from Venture::public_url — see
Venture::problem_type_base.
Sourcepub fn problem_type_base(&self) -> String
pub fn problem_type_base(&self) -> String
The base URI every problem type of this venture is served under:
the Venture::problem_base override when set, else
<public_url>/problems/, else about:blank.
A venture with no public URL has no URI of its own to name, and it
must never name another venture’s domain: RFC 9457 §4.2.1 reserves
about:blank for exactly this, so that is the fallback. Callers
branch on the slug — the part after the base; under the default base
everything after /problems/, auth/… namespaces included — which
is the stable part
(docs/ERRORS.md).
use cratefield_core::Venture;
// The default: under the venture's own public URL.
let v = Venture::new("acme", "acme.example").public_url("https://acme.example/");
assert_eq!(v.problem_type_base(), "https://acme.example/problems/");
// An explicit override wins, normalized to one trailing slash.
let v = v.problem_base("https://errors.acme.example/types/");
assert_eq!(v.problem_type_base(), "https://errors.acme.example/types/");
let v = v.problem_base("https://errors.acme.example/types");
assert_eq!(v.problem_type_base(), "https://errors.acme.example/types/");
// No public URL: the RFC 9457 default, never someone else's domain.
let v = Venture::new("acme", "acme.example").public_url(" ");
assert_eq!(v.problem_type_base(), "about:blank");