2023-04-03 08:57:51 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
2023-06-08 16:02:36 +00:00
|
|
|
#include <variant>
|
2023-04-03 08:57:51 +00:00
|
|
|
#include <nlohmann/json.hpp>
|
2023-04-06 12:24:09 +00:00
|
|
|
#include "blankie/murl.h"
|
2023-04-03 08:57:51 +00:00
|
|
|
|
2023-06-08 16:02:36 +00:00
|
|
|
struct IPConnection {
|
|
|
|
std::string address;
|
|
|
|
int port;
|
|
|
|
};
|
|
|
|
struct UnixConnection {
|
|
|
|
std::string unix;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RedisConfig {
|
|
|
|
std::variant<IPConnection, UnixConnection> connection_method;
|
|
|
|
std::optional<std::string> username;
|
|
|
|
std::optional<std::string> password;
|
|
|
|
};
|
|
|
|
|
2023-04-03 08:57:51 +00:00
|
|
|
struct Config {
|
|
|
|
std::string bind_host = "127.0.0.1";
|
|
|
|
int bind_port = 8080;
|
2023-04-06 12:24:09 +00:00
|
|
|
blankie::murl::Url image_proxy_url{"https://i.pixiv.cat"};
|
2023-06-04 05:08:49 +00:00
|
|
|
std::optional<std::string> canonical_origin;
|
2023-06-08 16:02:36 +00:00
|
|
|
std::optional<RedisConfig> redis_config;
|
2023-04-03 08:57:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Config load_config(const char* path);
|
|
|
|
void from_json(const nlohmann::json& j, Config& config);
|