dynamic base url
This commit is contained in:
16
src/api.rs
16
src/api.rs
@@ -119,6 +119,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
.and_then(|h| h.to_str().ok())
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
let public_url_base = format!("{}://{}", req.connection_info().scheme(), host);
|
||||
let mut status = Status::new();
|
||||
|
||||
for (provider_name, provider) in ALL_PROVIDERS.iter() {
|
||||
@@ -126,7 +127,12 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
provider.get_channel(clientversion.clone())
|
||||
}));
|
||||
match channel_result {
|
||||
Ok(Some(channel)) => status.add_channel(channel),
|
||||
Ok(Some(mut channel)) => {
|
||||
if channel.favicon.starts_with('/') {
|
||||
channel.favicon = format!("{}{}", public_url_base, channel.favicon);
|
||||
}
|
||||
status.add_channel(channel)
|
||||
}
|
||||
Ok(None) => {}
|
||||
Err(payload) => {
|
||||
let panic_msg = panic_payload_to_string(payload);
|
||||
@@ -134,7 +140,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
}
|
||||
}
|
||||
}
|
||||
status.iconUrl = format!("http://{}/favicon.ico", host).to_string();
|
||||
status.iconUrl = format!("{}/favicon.ico", public_url_base).to_string();
|
||||
Ok(web::HttpResponse::Ok().json(&status))
|
||||
}
|
||||
|
||||
@@ -245,12 +251,18 @@ async fn videos_post(
|
||||
.to_string();
|
||||
let duration = video_request.duration.as_deref().unwrap_or("").to_string();
|
||||
let sexuality = video_request.sexuality.as_deref().unwrap_or("").to_string();
|
||||
let public_url_base = format!(
|
||||
"{}://{}",
|
||||
req.connection_info().scheme(),
|
||||
req.connection_info().host()
|
||||
);
|
||||
let options = ServerOptions {
|
||||
featured: Some(featured),
|
||||
category: Some(category),
|
||||
sites: Some(sites),
|
||||
filter: Some(filter),
|
||||
language: Some(language),
|
||||
public_url_base: Some(public_url_base),
|
||||
requester: Some(requester),
|
||||
network: Some(network),
|
||||
stars: Some(stars),
|
||||
|
||||
Reference in New Issue
Block a user