This project demonstrates the linking of additional HTTP filters with the Envoy binary.
A new filter sample which adds a HTTP header is introduced.
Integration tests demonstrating the filter's end-to-end behavior are
also provided.
To build the Envoy static binary:
git submodule update --initbazel build //http-filter-example:envoy
To run the sample integration test:
bazel test //http-filter-example:http_filter_integration_test
See the network filter example.
- The main task is to write a class that implements the interface
Envoy::Http::StreamDecoderFilteras inhttp_filter.handhttp_filter.cc, which contains functions that handle http headers, data, and trailers. Note that this is an example of decoder filters, and to write encoder filters or decoder/encoder filters you need to implementEnvoy::Http::StreamEncoderFilterorEnvoy::Http::StreamFilterinstead. - You also need a class that implements
Envoy::Server::Configuration::NamedHttpFilterConfigFactoryto enable the Envoy binary to find your filter, as inhttp_filter_config.cc. It should be linked to the Envoy binary by modifyingBUILDfile. - Finally, you need to modify the Envoy config file to add your filter to the
filter chain for a particular HTTP route configuration. For instance, if you
wanted to change the front-proxy example to chain our
samplefilter, you'd need to modify its config to look like
http_filters:
- name: sample # before envoy.router because order matters!
config:
key: via
val: sample-filter
- name: envoy.router
config: {}