1
#include "source/extensions/matching/input_matchers/metadata/matcher.h"
2

            
3
namespace Envoy {
4
namespace Extensions {
5
namespace Matching {
6
namespace InputMatchers {
7
namespace Metadata {
8
namespace {
9
using ::Envoy::Matcher::MatchResult;
10
}
11

            
12
Matcher::Matcher(const Envoy::Matchers::ValueMatcherConstSharedPtr value_matcher, const bool invert)
13
13
    : value_matcher_(value_matcher), invert_(invert) {}
14

            
15
29
MatchResult Matcher::match(const Envoy::Matcher::DataInputGetResult& input) {
16
29
  if (auto match_data = input.customData<Matching::Http::MetadataInput::MetadataMatchData>();
17
29
      match_data) {
18
27
    if (value_matcher_->match(match_data->value_) ^ invert_) {
19
10
      return MatchResult::Matched;
20
10
    }
21
27
  }
22
19
  return MatchResult::NoMatch;
23
29
}
24

            
25
} // namespace Metadata
26
} // namespace InputMatchers
27
} // namespace Matching
28
} // namespace Extensions
29
} // namespace Envoy