From 2ff4ce015f6da151f988242947b9cb58d8ecde2e Mon Sep 17 00:00:00 2001 From: nekobit Date: Mon, 10 Oct 2022 03:37:30 +0000 Subject: [PATCH] Instance with https helper FossilOrigin-Name: 91d6b95d07e28d41208ba07e07dd8740022128313b210e53faca22af841f8ff7 --- src/instance/instance.cpp | 30 ++++++++++++++++++++++++++++++ src/instance/instance.h | 27 +++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/instance/instance.cpp create mode 100644 src/instance/instance.h diff --git a/src/instance/instance.cpp b/src/instance/instance.cpp new file mode 100644 index 0000000..871a9ff --- /dev/null +++ b/src/instance/instance.cpp @@ -0,0 +1,30 @@ +/* + * Wormhole - Federated social network + * Copyright (C) 2022 Nekobit + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "instance.h" +#include "config/config_loader.h" + +using namespace std::string_literals; + +const std::string& Instance::instance_host_https(bool append_slash /* = false */) +{ + static const std::string inst = "https://"s + Config::instance().config.instance.host; + static const std::string inst_slashed = inst + "/"; + return append_slash ? inst_slashed : inst; +} + diff --git a/src/instance/instance.h b/src/instance/instance.h new file mode 100644 index 0000000..88c5f5f --- /dev/null +++ b/src/instance/instance.h @@ -0,0 +1,27 @@ +/* + * Wormhole - Federated social network + * Copyright (C) 2022 Nekobit + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "config/config_loader.h" +#include + +namespace Instance +{ + const std::string& instance_host_https(bool append_slash = false); +}