1
#pragma once
2

            
3
#include "envoy/matcher/matcher.h"
4

            
5
#include "source/common/common/matchers.h"
6

            
7
namespace Envoy {
8
namespace Matcher {
9

            
10
class StringInputMatcher : public InputMatcher, Logger::Loggable<Logger::Id::matcher> {
11
public:
12
  template <class StringMatcherType>
13
  explicit StringInputMatcher(const StringMatcherType& matcher,
14
                              Server::Configuration::CommonFactoryContext& context)
15
1220
      : matcher_(matcher, context) {}
16

            
17
2444
  MatchResult match(const DataInputGetResult& input) override {
18
2444
    const auto data = input.stringData();
19
2444
    if (data && matcher_.match(*data)) {
20
751
      return MatchResult::Matched;
21
751
    }
22
    // Return false when input is empty.(i.e., input is absl::monostate).
23
1693
    return MatchResult::NoMatch;
24
2444
  }
25

            
26
private:
27
  const Matchers::StringMatcherImpl matcher_;
28
};
29

            
30
} // namespace Matcher
31
} // namespace Envoy