A HTTP request-response relay used by Hoppscotch Desktop and Hoppscotch Agent for more advanced request handling including custom headers, certificates, proxies, and local system integration.
[!IMPORTANT] This crate is only available via GitHub and not published on crates.io right now.
Add to your Cargo.toml
:
[dependencies]
relay = { git = "https://github.com/CuriousCorrelation/relay.git" }
use relay::{Request, Response, execute};
let request = Request {
id: 1,
url: "https://api.example.com".to_string(),
method: Method::Get,
version: Version::Http2,
// ... configure other options
};
let response = execute(request).await?;
[!NOTE] All requests are executed asynchronously and can be cancelled using the
cancel(request_id)
function.
[!TIP] You can configure certificate validation, host verification, and custom certificates:
let security_config = SecurityConfig {
validate_certificates: Some(true),
verify_host: Some(true),
certificates: Some(CertificateConfig {
client: Some(CertificateType::Pem {
cert: cert_data,
key: key_data
}),
ca: Some(vec![ca_cert_data])
})
};
The crate uses a custom error type RelayError
that provides information about failures:
#[derive(Error)]
pub enum RelayError {
Network { message: String, cause: Option<String> },
Certificate { message: String, cause: Option<String> },
Parse { message: String, cause: Option<String> },
// ... other variants
}
[!WARNING] This crate uses custom forks of some dependencies for NTLM support and consistent OpenSSL backend across platforms.
Code: (c) 2024 - CuriousCorrelation
MIT or MIT/Apache 2.0 where applicable.