Lines
100 %
Functions
#include "source/extensions/matching/actions/format_string/config.h"
#include "envoy/registry/registry.h"
#include "source/common/formatter/substitution_format_string.h"
#include "source/common/http/header_map_impl.h"
#include "source/common/protobuf/utility.h"
namespace Envoy {
namespace Extensions {
namespace Matching {
namespace Actions {
namespace FormatString {
const Network::FilterChain*
ActionImpl::get(const Server::Configuration::FilterChainsByName& filter_chains_by_name,
const StreamInfo::StreamInfo& info) const {
const std::string name = formatter_->format({}, info);
const auto chain_match = filter_chains_by_name.find(name);
if (chain_match != filter_chains_by_name.end()) {
return chain_match->second.get();
}
return nullptr;
Matcher::ActionConstSharedPtr
ActionFactory::createAction(const Protobuf::Message& proto_config,
FilterChainActionFactoryContext& context,
ProtobufMessage::ValidationVisitor& validator) {
const auto& config =
MessageUtil::downcastAndValidate<const envoy::config::core::v3::SubstitutionFormatString&>(
proto_config, validator);
Server::GenericFactoryContextImpl generic_context(context, validator);
Formatter::FormatterConstSharedPtr formatter = THROW_OR_RETURN_VALUE(
Formatter::SubstitutionFormatStringUtils::fromProtoConfig(config, generic_context),
Formatter::FormatterPtr);
return std::make_shared<ActionImpl>(std::move(formatter));
REGISTER_FACTORY(ActionFactory, Matcher::ActionFactory<FilterChainActionFactoryContext>);
} // namespace FormatString
} // namespace Actions
} // namespace Matching
} // namespace Extensions
} // namespace Envoy