1
#include "source/extensions/http/early_header_mutation/header_mutation/header_mutation.h"
2

            
3
#include "envoy/config/common/mutation_rules/v3/mutation_rules.pb.h"
4

            
5
#include "source/common/http/header_map_impl.h"
6

            
7
namespace Envoy {
8
namespace Extensions {
9
namespace Http {
10
namespace EarlyHeaderMutation {
11
namespace HeaderMutation {
12

            
13
HeaderMutation::HeaderMutation(const ProtoHeaderMutation& mutations,
14
                               Server::Configuration::ServerFactoryContext& context)
15
4
    : mutations_(THROW_OR_RETURN_VALUE(
16
          Envoy::Http::HeaderMutations::create(mutations.mutations(), context),
17
4
          std::unique_ptr<Envoy::Http::HeaderMutations>)) {}
18

            
19
bool HeaderMutation::mutate(Envoy::Http::RequestHeaderMap& headers,
20
3
                            const StreamInfo::StreamInfo& stream_info) const {
21
3
  mutations_->evaluateHeaders(headers, {&headers}, stream_info);
22
3
  return true;
23
3
}
24

            
25
} // namespace HeaderMutation
26
} // namespace EarlyHeaderMutation
27
} // namespace Http
28
} // namespace Extensions
29
} // namespace Envoy