Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.pb.h" 4 : #include "envoy/http/codes.h" 5 : #include "envoy/http/header_map.h" 6 : #include "envoy/server/filter_config.h" 7 : 8 : #include "source/common/stream_info/stream_info_impl.h" 9 : 10 : namespace Envoy { 11 : namespace LocalReply { 12 : 13 : class LocalReply { 14 : public: 15 310 : virtual ~LocalReply() = default; 16 : 17 : /** 18 : * rewrite the response status code, body and content_type. 19 : * @param request_headers supplies the information about request headers required by filters. 20 : * @param stream_info supplies the information about streams required by filters. 21 : * @param code status code. 22 : * @param body response body. 23 : * @param content_type response content_type. 24 : */ 25 : virtual void rewrite(const Http::RequestHeaderMap* request_headers, 26 : Http::ResponseHeaderMap& response_headers, 27 : StreamInfo::StreamInfo& stream_info, Http::Code& code, std::string& body, 28 : absl::string_view& content_type) const PURE; 29 : }; 30 : 31 : using LocalReplyPtr = std::unique_ptr<LocalReply>; 32 : 33 : /** 34 : * Access log filter factory that reads from proto. 35 : */ 36 : class Factory { 37 : public: 38 : /** 39 : * Create a LocalReply object from ProtoConfig 40 : */ 41 : static LocalReplyPtr 42 : create(const envoy::extensions::filters::network::http_connection_manager::v3::LocalReplyConfig& 43 : config, 44 : Server::Configuration::FactoryContext& context); 45 : 46 : /** 47 : * Create a default LocalReply object with empty config. 48 : * It is used at places without Server::Configuration::FactoryContext. 49 : */ 50 : static LocalReplyPtr createDefault(); 51 : }; 52 : 53 : } // namespace LocalReply 54 : } // namespace Envoy