use url::Url;
#[cfg(feature = "v1")]
const V1_REQ_CONTENT_TYPE: &str = "text/plain";
#[cfg(feature = "v2")]
const V2_REQ_CONTENT_TYPE: &str = "message/ohttp-req";
#[non_exhaustive]
#[derive(Debug, Clone)]
pub struct Request {
pub url: String,
pub content_type: &'static str,
pub body: Vec<u8>,
}
impl Request {
#[cfg(feature = "v1")]
pub(crate) fn new_v1(url: &Url, body: &[u8]) -> Self {
Self { url: url.to_string(), content_type: V1_REQ_CONTENT_TYPE, body: body.to_vec() }
}
#[cfg(feature = "v2")]
pub(crate) fn new_v2(
url: &Url,
body: &[u8; crate::directory::ENCAPSULATED_MESSAGE_BYTES],
) -> Self {
Self { url: url.to_string(), content_type: V2_REQ_CONTENT_TYPE, body: body.to_vec() }
}
}