Refactor url handling
This commit is contained in:
@@ -17,7 +17,7 @@ bytes = "1.4.0"
|
||||
chrono = { version = "0.4.19", features = ["serde"] }
|
||||
futures-util = "0.3.14"
|
||||
tracing = "0.1.37"
|
||||
url = "2.2"
|
||||
url = "2.5.0"
|
||||
num-traits = "0.2.16"
|
||||
hex = "0.4.3"
|
||||
err = { path = "../err" }
|
||||
|
||||
@@ -18,6 +18,7 @@ use err::Error;
|
||||
use futures_util::Stream;
|
||||
use futures_util::StreamExt;
|
||||
use http::Request;
|
||||
use http::Uri;
|
||||
use range::evrange::NanoRange;
|
||||
use range::evrange::PulseRange;
|
||||
use range::evrange::SeriesRange;
|
||||
@@ -3188,3 +3189,15 @@ impl ReqCtx {
|
||||
}
|
||||
|
||||
pub type ReqCtxArc = std::sync::Arc<ReqCtx>;
|
||||
|
||||
pub fn req_uri_to_url(uri: &Uri) -> Result<Url, Error> {
|
||||
if uri.scheme().is_none() {
|
||||
format!("dummy:{uri}")
|
||||
.parse()
|
||||
.map_err(|_| Error::with_msg_no_trace(format!("can not use uri {uri}")))
|
||||
} else {
|
||||
uri.to_string()
|
||||
.parse()
|
||||
.map_err(|_| Error::with_msg_no_trace(format!("can not use uri {uri}")))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user