Line data Source code
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 0 : Server::Configuration::ServerFactoryContext& context) override { 24 0 : const auto& cel_matcher_config = 25 0 : dynamic_cast<const ::xds::type::matcher::v3::CelMatcher&>(config); 26 0 : CelMatcherSharedPtr cel_matcher = 27 0 : std::make_shared<::xds::type::matcher::v3::CelMatcher>(cel_matcher_config); 28 : 29 0 : return [cel_matcher = std::move(cel_matcher), &context] { 30 0 : return std::make_unique<CelInputMatcher>(cel_matcher, 31 0 : Filters::Common::Expr::getBuilder(context)); 32 0 : }; 33 0 : } 34 : 35 1 : ProtobufTypes::MessagePtr createEmptyConfigProto() override { 36 1 : return std::make_unique<CelMatcher>(); 37 1 : } 38 : 39 39 : 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