mirror of
https://github.com/zerotier/pg_consul.git
synced 2026-05-22 16:22:07 -07:00
a5c927b1c9
Round out consul_kv with GET, PUT, and DELETE support. Recursive works with DELETE. Both PUT and DELETE support the cas argument, -C.
36 lines
791 B
C++
36 lines
791 B
C++
#ifndef CPR_PAYLOAD_H
|
|
#define CPR_PAYLOAD_H
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <initializer_list>
|
|
|
|
#include "defines.h"
|
|
|
|
namespace cpr {
|
|
|
|
struct Pair {
|
|
template <typename KeyType, typename ValueType,
|
|
typename std::enable_if<!std::is_integral<ValueType>::value, bool>::type = true>
|
|
Pair(KeyType&& p_key, ValueType&& p_value)
|
|
: key{CPR_FWD(p_key)}, value{CPR_FWD(p_value)} {}
|
|
template <typename KeyType>
|
|
Pair(KeyType&& p_key, const int& p_value)
|
|
: key{CPR_FWD(p_key)}, value{std::to_string(p_value)} {}
|
|
|
|
std::string key;
|
|
std::string value;
|
|
};
|
|
|
|
class Payload {
|
|
public:
|
|
Payload(const std::initializer_list<Pair>& pairs);
|
|
Payload(const std::string& data);
|
|
|
|
std::string content;
|
|
};
|
|
|
|
} // namespace cpr
|
|
|
|
#endif
|