use super::super::{context::*, url::*};
use std::fmt;
#[derive(Clone, Debug)]
pub struct HttpUrl {
pub url: url::Url,
pub(crate) context: UrlContextRef,
}
impl HttpUrl {
pub fn new(context: &UrlContextRef, url: url::Url) -> Self {
Self { url, context: context.clone() }
}
pub fn new_with(&self, path: &str) -> Self {
let mut url = self.url.clone();
url.set_path(path);
url.set_query(None);
url.set_fragment(None);
Self::new(&self.context, url)
}
}
impl fmt::Display for HttpUrl {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "{}", self.url)
}
}
impl Into<UrlRef> for HttpUrl {
fn into(self) -> UrlRef {
Box::new(self)
}
}