forked from envoyproxy/envoy-filter-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
http_filter.cc
45 lines (31 loc) · 1.19 KB
/
http_filter.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <string>
#include "http_filter.h"
#include "envoy/server/filter_config.h"
namespace Envoy {
namespace Http {
HttpSampleDecoderFilterConfig::HttpSampleDecoderFilterConfig(
const sample::Decoder& proto_config)
: key_(proto_config.key()), val_(proto_config.val()) {}
HttpSampleDecoderFilter::HttpSampleDecoderFilter(HttpSampleDecoderFilterConfigSharedPtr config)
: config_(config) {}
HttpSampleDecoderFilter::~HttpSampleDecoderFilter() {}
void HttpSampleDecoderFilter::onDestroy() {}
const LowerCaseString HttpSampleDecoderFilter::headerKey() const {
return LowerCaseString(config_->key());
}
const std::string HttpSampleDecoderFilter::headerValue() const {
return config_->val();
}
FilterHeadersStatus HttpSampleDecoderFilter::decodeHeaders(RequestHeaderMap& headers, bool) {
// add a header
headers.addCopy(headerKey(), headerValue());
return FilterHeadersStatus::Continue;
}
FilterDataStatus HttpSampleDecoderFilter::decodeData(Buffer::Instance&, bool) {
return FilterDataStatus::Continue;
}
void HttpSampleDecoderFilter::setDecoderFilterCallbacks(StreamDecoderFilterCallbacks& callbacks) {
decoder_callbacks_ = &callbacks;
}
} // namespace Http
} // namespace Envoy