#include "config.hpp" #include #include #include #include namespace simple_object_storage { bool load_config(const std::string& config_path, ServerConfig& config) { try { std::ifstream file(config_path); if (!file.is_open()) { std::cerr << "Failed to open config file: " << config_path << std::endl; return false; } nlohmann::json j; file >> j; // Parse write tokens if (j.contains("write_tokens")) { config.write_tokens = j["write_tokens"].get>(); } // Parse object store path if (j.contains("object_store_path")) { config.object_store_path = j["object_store_path"].get(); } // Parse host (optional) if (j.contains("host")) { config.host = j["host"].get(); } // Parse port (optional) if (j.contains("port")) { config.port = j["port"].get(); } return true; } catch (const std::exception& e) { std::cerr << "Error parsing config file: " << e.what() << std::endl; return false; } } } // namespace simple_object_storage