forked from envoyproxy/envoy-filter-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
http_filter.h
48 lines (34 loc) · 1.25 KB
/
http_filter.h
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
46
47
48
#pragma once
#include <string>
#include "extensions/filters/http/common/pass_through_filter.h"
#include "http-filter-example/http_filter.pb.h"
namespace Envoy {
namespace Http {
class HttpSampleDecoderFilterConfig {
public:
HttpSampleDecoderFilterConfig(const sample::Decoder& proto_config);
const std::string& key() const { return key_; }
const std::string& val() const { return val_; }
private:
const std::string key_;
const std::string val_;
};
using HttpSampleDecoderFilterConfigSharedPtr = std::shared_ptr<HttpSampleDecoderFilterConfig>;
class HttpSampleDecoderFilter : public PassThroughDecoderFilter {
public:
HttpSampleDecoderFilter(HttpSampleDecoderFilterConfigSharedPtr);
~HttpSampleDecoderFilter();
// Http::StreamFilterBase
void onDestroy() override;
// Http::StreamDecoderFilter
FilterHeadersStatus decodeHeaders(RequestHeaderMap&, bool) override;
FilterDataStatus decodeData(Buffer::Instance&, bool) override;
void setDecoderFilterCallbacks(StreamDecoderFilterCallbacks&) override;
private:
const HttpSampleDecoderFilterConfigSharedPtr config_;
StreamDecoderFilterCallbacks* decoder_callbacks_;
const LowerCaseString headerKey() const;
const std::string headerValue() const;
};
} // namespace Http
} // namespace Envoy