droplet 1.3.0
A multipurpose Discord bot with the hacker in mind
Loading...
Searching...
No Matches
Secrets.hpp
Go to the documentation of this file.
1/*
2 * (c) Copyright erarnitox.de - All rights reserved
3 * Author: Erarnitox <david@erarnitox.de>
4 *
5 * License: MIT License
6 *
7 * Description: This class provides a Singleton to access secrets
8 *
9 * Documentation: https://droplet.erarnitox.de/doxygen/html/database
10 */
11
12#pragma once
13
14#include <Poco/JSON/Object.h>
15#include <Poco/JSON/Parser.h>
16
17#include <cstddef>
18#include <string>
19
20//-----------------------------------------------------
21//
22//-----------------------------------------------------
23class Secrets {
24 public:
25 static Secrets& getInstance();
26 [[nodiscard]] std::string getSecret(const std::string& key, const std::string& fallback = "") const;
27 [[nodiscard]] std::string requireSecret(const std::string& key, std::size_t min_len) const;
28
29 private:
30 Secrets();
31 Secrets(const Secrets&) = delete;
32 Secrets& operator=(const Secrets&) = delete;
33
34 Poco::JSON::Object::Ptr secrets;
35};
std::string getSecret(const std::string &key, const std::string &fallback="") const
Definition Secrets.cpp:28
static Secrets & getInstance()
Definition Secrets.cpp:20
std::string requireSecret(const std::string &key, std::size_t min_len) const
Definition Secrets.cpp:36