diff --git a/examples/challenge_response.rs b/examples/challenge_response.rs index c893a2f..c910a3f 100644 --- a/examples/challenge_response.rs +++ b/examples/challenge_response.rs @@ -20,10 +20,8 @@ fn my_evidence_builder(nonce: &[u8], accept: &[String]) -> Result<(Vec, Stri fn main() { let base_url = "https://localhost:8080"; - let discovery_api_endpoint = format!("{}{}", base_url, "/.well-known/veraison/verification"); - let discovery = DiscoveryBuilder::new() - .with_url(discovery_api_endpoint) + .with_base_url(base_url.into()) .with_root_certificate("veraison-root.crt".into()) .build() .expect("Failed to start API discovery with the service"); diff --git a/src/lib.rs b/src/lib.rs index af02b1d..92de9db 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -376,10 +376,15 @@ impl DiscoveryBuilder { } } - /// Use this method to supply the URL of the discovery endpoint, e.g.: - /// "https://veraison.example/.well-known/veraison/verification" - pub fn with_url(mut self, v: String) -> DiscoveryBuilder { - self.url = Some(v); + /// Use this method to supply the base URL of the discovery endpoint, e.g. + /// "https://veraison.example" in the full + /// "https://veraison.example/.well-known/veraison/verification". + /// This hides / encapsulate the details of what the actual URL looks like. + pub fn with_base_url(mut self, base_url: String) -> DiscoveryBuilder { + self.url = Some(format!( + "{}{}", + base_url, "/.well-known/veraison/verification" + )); self } @@ -710,14 +715,8 @@ mod tests { .mount(&mock_server) .await; - let discovery_api_endpoint = format!( - "{}{}", - mock_server.uri(), - "/.well-known/veraison/verification" - ); - let discovery = DiscoveryBuilder::new() - .with_url(discovery_api_endpoint) + .with_base_url(mock_server.uri()) .build() .expect("Failed to create Discovery client.");