11#include <unordered_set>
14#include <userver/engine/task/inherited_variable.hpp>
16USERVER_NAMESPACE_BEGIN
20using BaggageProperties =
21 std::vector<std::pair<std::string, std::optional<std::string>>>;
29 explicit BaggageException(
const std::string& message)
30 : std::runtime_error(message) {}
40 BaggageEntryProperty(std::string_view key,
41 std::optional<std::string_view> value = std::nullopt);
42 std::string ToString()
const;
43 std::optional<std::string> GetValue()
const;
44 std::string GetKey()
const;
47 const std::string_view key_;
48 std::optional<std::string_view> value_;
59 BaggageEntry(std::string_view key, std::string_view value,
60 std::vector<BaggageEntryProperty> properties);
61 std::string ToString()
const;
62 std::string GetValue()
const;
63 std::string GetKey()
const;
77 void ConcatenateWith(std::string& header)
const;
78 const std::string_view key_;
79 std::string_view value_;
80 std::vector<BaggageEntryProperty> properties_;
91 Baggage(std::string header, std::unordered_set<std::string> allowed_keys);
92 Baggage(
const Baggage&)
noexcept;
95 std::string ToString()
const;
115 BaggageProperties properties);
127 std::string_view property);
134 void CreateResultHeader();
136 std::string header_value_;
137 std::unordered_set<std::string> allowed_keys_;
138 std::vector<BaggageEntry> entries_;
142 std::string result_header_;
145 bool is_valid_header_ =
true;
150 std::string header, std::unordered_set<std::string> allowed_keys);
153bool HasInvalidSymbols(
const T& obj) {
154 return std::find_if(obj.begin(), obj.end(), [](
unsigned char x) {
155 return x ==
',' || x ==
';' || x ==
'=' || std::isspace(x);
159inline engine::TaskInheritedVariable<
Baggage> kInheritedBaggage;