1
#pragma once
2

            
3
#include "envoy/config/core/v3/substitution_format_string.pb.h"
4
#include "envoy/config/core/v3/substitution_format_string.pb.validate.h"
5
#include "envoy/formatter/substitution_formatter.h"
6
#include "envoy/matcher/matcher.h"
7
#include "envoy/server/factory_context.h"
8

            
9
#include "source/common/matcher/matcher.h"
10

            
11
namespace Envoy {
12
namespace Extensions {
13
namespace Matching {
14
namespace Actions {
15
namespace FormatString {
16

            
17
class ActionImpl : public Matcher::ActionBase<envoy::config::core::v3::SubstitutionFormatString,
18
                                              Server::Configuration::FilterChainBaseAction> {
19
public:
20
1
  ActionImpl(Formatter::FormatterConstSharedPtr formatter) : formatter_(std::move(formatter)) {}
21
  const Network::FilterChain*
22
  get(const Server::Configuration::FilterChainsByName& filter_chains_by_name,
23
      const StreamInfo::StreamInfo& info) const override;
24

            
25
private:
26
  const Formatter::FormatterConstSharedPtr formatter_;
27
};
28

            
29
using FilterChainActionFactoryContext = Server::Configuration::ServerFactoryContext;
30
class ActionFactory : public Matcher::ActionFactory<FilterChainActionFactoryContext> {
31
public:
32
5
  std::string name() const override { return "envoy.matching.actions.format_string"; }
33
  Matcher::ActionConstSharedPtr
34
  createAction(const Protobuf::Message& proto_config, FilterChainActionFactoryContext& context,
35
               ProtobufMessage::ValidationVisitor& validator) override;
36
1
  ProtobufTypes::MessagePtr createEmptyConfigProto() override {
37
1
    return std::make_unique<envoy::config::core::v3::SubstitutionFormatString>();
38
1
  }
39
};
40

            
41
} // namespace FormatString
42
} // namespace Actions
43
} // namespace Matching
44
} // namespace Extensions
45
} // namespace Envoy