libravatarserv/src/config.cpp

34 lines
1.1 KiB
C++

/* This file is part of libravatarserv.
* Copyright © 2022 tastytea <tastytea@tastytea.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.hpp"
#include "fs-compat.hpp"
#include "helpers.hpp"
namespace libravatarserv::config {
config read() {
config cfg;
cfg.avatar_dir = read_env("LIBRAVATARSERV_DIR", fs::current_path().c_str());
cfg.default_fallback = read_env("LIBRAVATARSERV_DEFAULT_FALLBACK", "404");
cfg.redirect = (read_env("LIBRAVATARSERV_REDIRECT") == "1");
return cfg;
}
} // namespace libravatarserv::config