1
#pragma once
2

            
3
#include <memory>
4
#include <string>
5

            
6
#include "envoy/matcher/matcher.h"
7

            
8
#include "source/common/protobuf/utility.h"
9
#include "source/extensions/matching/input_matchers/cel_matcher/matcher.h"
10

            
11
#include "xds/type/matcher/v3/cel.pb.h"
12

            
13
namespace Envoy {
14
namespace Extensions {
15
namespace Matching {
16
namespace InputMatchers {
17
namespace CelMatcher {
18

            
19
class CelInputMatcherFactory : public ::Envoy::Matcher::InputMatcherFactory {
20
public:
21
  InputMatcherFactoryCb
22
  createInputMatcherFactoryCb(const Protobuf::Message& config,
23
116
                              Server::Configuration::ServerFactoryContext& context) override {
24
116
    const auto& cel_matcher_config =
25
116
        dynamic_cast<const ::xds::type::matcher::v3::CelMatcher&>(config);
26
116
    CelMatcherSharedPtr cel_matcher =
27
116
        std::make_shared<::xds::type::matcher::v3::CelMatcher>(cel_matcher_config);
28

            
29
116
    return [cel_matcher = std::move(cel_matcher), &context] {
30
115
      return std::make_unique<CelInputMatcher>(cel_matcher,
31
115
                                               Filters::Common::Expr::getBuilder(context));
32
115
    };
33
116
  }
34

            
35
135
  ProtobufTypes::MessagePtr createEmptyConfigProto() override {
36
135
    return std::make_unique<CelMatcher>();
37
135
  }
38

            
39
345
  std::string name() const override { return "envoy.matching.matchers.cel_matcher"; }
40
};
41

            
42
} // namespace CelMatcher
43
} // namespace InputMatchers
44
} // namespace Matching
45
} // namespace Extensions
46
} // namespace Envoy