mirror of
https://github.com/mikedilger/chorus.git
synced 2026-04-03 06:41:16 +00:00
Change config.url() to config.uri_parts() so that (later) path_and_query can be swapped out
This commit is contained in:
parent
3f26b47008
commit
af1d992ce7
@ -234,7 +234,7 @@ impl Default for Config {
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn url(&self, inner: Uri, http: bool) -> Result<Uri, Error> {
|
||||
pub fn uri_parts(&self, inner: Uri, http: bool) -> Result<http::uri::Parts, Error> {
|
||||
let mut uri_parts = inner.into_parts();
|
||||
let scheme = match (self.use_tls, http) {
|
||||
(false, false) => Scheme::from_str("ws").unwrap(),
|
||||
@ -245,6 +245,6 @@ impl Config {
|
||||
uri_parts.scheme = Some(scheme);
|
||||
let authority = Authority::from_str(&format!("{}:{}", self.hostname, self.port))?;
|
||||
uri_parts.authority = Some(authority);
|
||||
Ok(Uri::from_parts(uri_parts)?)
|
||||
Ok(uri_parts)
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +86,11 @@ pub async fn check_auth(request: Request<Incoming>) -> Result<Value, Error> {
|
||||
if let Some(u) = tags.get_value(b"u") {
|
||||
let auth_url = String::from_utf8(u.to_owned())?;
|
||||
let actual_url = {
|
||||
let uri = GLOBALS.config.read().url(request.uri().to_owned(), true)?;
|
||||
let uri_parts = GLOBALS
|
||||
.config
|
||||
.read()
|
||||
.uri_parts(request.uri().to_owned(), true)?;
|
||||
let uri = http::Uri::from_parts(uri_parts)?;
|
||||
format!("{}", uri)
|
||||
};
|
||||
|
||||
|
||||
@ -43,6 +43,8 @@ pub async fn serve_http(
|
||||
}
|
||||
}
|
||||
|
||||
let uri = request.uri().to_owned();
|
||||
|
||||
// Try blossom if enabled
|
||||
if GLOBALS.config.read().blossom_directory.is_some() {
|
||||
match blossom::handle(&request).await {
|
||||
@ -55,7 +57,8 @@ pub async fn serve_http(
|
||||
}
|
||||
}
|
||||
|
||||
log::debug!(target: "Client", "{}: HTTP request for {}", peer, request.uri());
|
||||
log::debug!(target: "Client", "{}: HTTP request for {}", peer, uri);
|
||||
|
||||
let response = Response::builder()
|
||||
.header("Access-Control-Allow-Origin", "*")
|
||||
.header("Access-Control-Allow-Headers", "*")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user