Line data Source code
1 : #pragma once 2 : 3 : #include <memory> 4 : #include <string> 5 : 6 : #include "envoy/common/pure.h" 7 : #include "envoy/config/typed_config.h" 8 : #include "envoy/http/header_map.h" 9 : #include "envoy/server/factory_context.h" 10 : #include "envoy/stream_info/stream_info.h" 11 : 12 : namespace Envoy { 13 : namespace Http { 14 : 15 : /** 16 : * Interface class for early header mutation extensions. 17 : */ 18 : class EarlyHeaderMutation { 19 : public: 20 0 : virtual ~EarlyHeaderMutation() = default; 21 : 22 : /** 23 : * Mutate the request headers before routing, tracing or any filter processing. 24 : * 25 : * @param headers request headers to be mutated. 26 : * @param stream_info stream info. 27 : * @return true if the mutation is could be continued for the flollowing extensions. 28 : * Make no sense if there is no following extensions. 29 : */ 30 : virtual bool mutate(RequestHeaderMap& headers, 31 : const StreamInfo::StreamInfo& stream_info) const PURE; 32 : }; 33 : 34 : using EarlyHeaderMutationPtr = std::unique_ptr<EarlyHeaderMutation>; 35 : 36 : /* 37 : * A factory for creating early header mutation extensions. 38 : */ 39 : class EarlyHeaderMutationFactory : public Envoy::Config::TypedFactory { 40 : public: 41 8 : ~EarlyHeaderMutationFactory() override = default; 42 : 43 : /** 44 : * Creates a particular extension implementation. 45 : * 46 : * @param config supplies the configuration for the early mutation extension. 47 : * @return EarlyHeaderMutationPtr the extension instance. 48 : */ 49 : virtual EarlyHeaderMutationPtr 50 : createExtension(const Protobuf::Message& config, 51 : Server::Configuration::FactoryContext& context) PURE; 52 : 53 8 : std::string category() const override { return "envoy.http.early_header_mutation"; } 54 : }; 55 : 56 : using EarlyHeaderMutationFactoryPtr = std::unique_ptr<EarlyHeaderMutationFactory>; 57 : 58 : } // namespace Http 59 : } // namespace Envoy