Instance with https helper

FossilOrigin-Name: 91d6b95d07e28d41208ba07e07dd8740022128313b210e53faca22af841f8ff7
This commit is contained in:
nekobit 2022-10-10 03:37:30 +00:00
parent d0936aff15
commit 2ff4ce015f
2 changed files with 57 additions and 0 deletions

30
src/instance/instance.cpp Normal file
View file

@ -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 <https://www.gnu.org/licenses/>.
*/
#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;
}

27
src/instance/instance.h Normal file
View file

@ -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 <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "config/config_loader.h"
#include <string_view>
namespace Instance
{
const std::string& instance_host_https(bool append_slash = false);
}