mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-17 11:06:16 +02:00
Add custom URL prefix for HTTP URLs (#1260)
Co-authored-by: Johannes Pohl <johannes.pohl@badaix.de>
This commit is contained in:
parent
342eda02a0
commit
b5284301c5
4 changed files with 18 additions and 8 deletions
|
@ -100,6 +100,10 @@ doc_root = /usr/share/snapserver/snapweb
|
||||||
# use <hostname> as placeholder for your actual host name
|
# use <hostname> as placeholder for your actual host name
|
||||||
#host = <hostname>
|
#host = <hostname>
|
||||||
|
|
||||||
|
# Optional custom URL prefix for generated URLs where clients can reach
|
||||||
|
# cached album art, to e.g. match scheme behind a reverse proxy.
|
||||||
|
#url_prefix = https://<hostname>
|
||||||
|
|
||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ struct ServerSettings
|
||||||
std::vector<std::string> ssl_bind_to_address{{"0.0.0.0"}};
|
std::vector<std::string> ssl_bind_to_address{{"0.0.0.0"}};
|
||||||
std::string doc_root{""};
|
std::string doc_root{""};
|
||||||
std::string host{"<hostname>"};
|
std::string host{"<hostname>"};
|
||||||
|
std::string url_prefix{""};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Tcp
|
struct Tcp
|
||||||
|
|
|
@ -100,6 +100,7 @@ int main(int argc, char* argv[])
|
||||||
settings.http.ssl_bind_to_address.front(), &settings.http.ssl_bind_to_address[0]);
|
settings.http.ssl_bind_to_address.front(), &settings.http.ssl_bind_to_address[0]);
|
||||||
conf.add<Implicit<string>>("", "http.doc_root", "serve a website from the doc_root location", settings.http.doc_root, &settings.http.doc_root);
|
conf.add<Implicit<string>>("", "http.doc_root", "serve a website from the doc_root location", settings.http.doc_root, &settings.http.doc_root);
|
||||||
conf.add<Value<string>>("", "http.host", "Hostname or IP under which clients can reach this host", settings.http.host, &settings.http.host);
|
conf.add<Value<string>>("", "http.host", "Hostname or IP under which clients can reach this host", settings.http.host, &settings.http.host);
|
||||||
|
conf.add<Value<string>>("", "http.url_prefix", "URL prefix for generating album art URLs", settings.http.url_prefix, &settings.http.url_prefix);
|
||||||
|
|
||||||
// TCP RPC settings
|
// TCP RPC settings
|
||||||
conf.add<Value<bool>>("", "tcp.enabled", "enable TCP Json RPC)", settings.tcp.enabled, &settings.tcp.enabled);
|
conf.add<Value<bool>>("", "tcp.enabled", "enable TCP Json RPC)", settings.tcp.enabled, &settings.tcp.enabled);
|
||||||
|
|
|
@ -541,7 +541,11 @@ void PcmStream::setProperties(const Properties& properties)
|
||||||
auto md5 = ImageCache::instance().setImage(getName(), std::move(data), props.metadata->art_data->extension);
|
auto md5 = ImageCache::instance().setImage(getName(), std::move(data), props.metadata->art_data->extension);
|
||||||
|
|
||||||
std::stringstream url;
|
std::stringstream url;
|
||||||
url << "http://" << server_settings_.http.host << ":" << server_settings_.http.port << "/__image_cache?name=" << md5;
|
if (server_settings_.http.url_prefix == "") {
|
||||||
|
url << "http://" << server_settings_.http.host << ":" << server_settings_.http.port << "/__image_cache?name=" << md5;
|
||||||
|
} else {
|
||||||
|
url << server_settings_.http.url_prefix << "/__image_cache?name=" << md5;
|
||||||
|
}
|
||||||
props.metadata->art_url = url.str();
|
props.metadata->art_url = url.str();
|
||||||
}
|
}
|
||||||
else if (!props.metadata.has_value() || !props.metadata->art_data.has_value())
|
else if (!props.metadata.has_value() || !props.metadata->art_data.has_value())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue