pub fn validate_sync(url: &str, policy: Policy) -> Result<Validated, Error>Expand description
Synchronous version of validate.
This blocks the current thread while performing DNS resolution. Prefer the async version when possible.
This function works both inside and outside of a Tokio runtime. When called from outside a runtime, it creates a temporary one.
ยงExample
use url_jail::{validate_sync, Policy};
let result = validate_sync("https://example.com/api", Policy::PublicOnly)?;
println!("Safe to connect to {} ({})", result.host, result.ip);