Add proxy option for proxying images

This commit is contained in:
blankie 2023-04-04 21:32:51 +07:00
parent 5850bc7e6c
commit 5f004f5b45
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
3 changed files with 6 additions and 3 deletions

View File

@ -5,7 +5,7 @@
Config load_config(const char* path) {
File config_file(path, "r");
return nlohmann::json::parse(config_file.get());
return nlohmann::json::parse(config_file.get(), nullptr, true, true);
}
void from_json(const nlohmann::json& j, Config& config) {
@ -16,4 +16,5 @@ void from_json(const nlohmann::json& j, Config& config) {
if (config.bind_port < 0) {
throw std::invalid_argument("Invalid port to bind to: "s + std::to_string(config.bind_port));
}
j.at("image_proxy_url").get_to(config.image_proxy_url);
}

View File

@ -6,6 +6,7 @@
struct Config {
std::string bind_host = "127.0.0.1";
int bind_port = 8080;
std::string image_proxy_url = "https://i.pixiv.cat";
};
Config load_config(const char* path);

View File

@ -1,4 +1,5 @@
{
"bind_host": "127.0.0.1",
"bind_port": 8080
"bind_host": "127.0.0.1", // What address to bind to
"bind_port": 8080, // What port to bind to
"image_proxy_url": "https://i.pixiv.cat" // URL to proxy images to (see https://pixiv.cat/reverseproxy.html)
}