Add mapbox_api_key to settings

This commit is contained in:
Dan Paulat 2022-04-20 11:56:22 -05:00
parent ba64627f5d
commit a96e017917
7 changed files with 47 additions and 11 deletions

View file

@ -92,7 +92,8 @@ bool FromJsonInt64(const boost::json::object& json,
bool FromJsonString(const boost::json::object& json,
const std::string& key,
std::string& value,
const std::string& defaultValue)
const std::string& defaultValue,
size_t minLength)
{
const boost::json::value* jv = json.if_contains(key);
bool dirty = true;
@ -102,7 +103,20 @@ bool FromJsonString(const boost::json::object& json,
if (jv->is_string())
{
value = boost::json::value_to<std::string>(*jv);
dirty = false;
if (value.length() >= minLength)
{
dirty = false;
}
else
{
logger_->warn(
"{} is shorter than {} characters, setting to default: {}",
key,
minLength,
defaultValue);
value = defaultValue;
}
}
else
{

View file

@ -22,7 +22,8 @@ bool FromJsonInt64(const boost::json::object& json,
bool FromJsonString(const boost::json::object& json,
const std::string& key,
std::string& value,
const std::string& defaultValue);
const std::string& defaultValue,
size_t minLength = 0);
boost::json::value ReadJsonFile(const std::string& path);
void WriteJsonFile(const std::string& path,