Skip to content

Commit

Permalink
Use Http::PassThrough filter
Browse files Browse the repository at this point in the history
Signed-off-by: Wayne Zhang <[email protected]>
Change-Id: I27f0f7151f54781edb370f05c202d8987e9adf48
  • Loading branch information
qiwzhang authored and nareddyt committed Dec 17, 2019
1 parent 29de459 commit ca9ffa9
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 105 deletions.
1 change: 1 addition & 0 deletions src/envoy/http/backend_auth/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ envoy_cc_library(
":config_parser_lib",
"//api/envoy/http/backend_auth:config_proto_cc_proto",
"//src/envoy/utils:filter_state_utils_lib",
"@envoy//source/extensions/filters/http/common:pass_through_filter_lib",
],
)

Expand Down
13 changes: 0 additions & 13 deletions src/envoy/http/backend_auth/filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,6 @@ FilterHeadersStatus Filter::decodeHeaders(HeaderMap& headers, bool) {
return FilterHeadersStatus::Continue;
}

FilterDataStatus Filter::decodeData(Buffer::Instance&, bool) {
return FilterDataStatus::Continue;
}

FilterTrailersStatus Filter::decodeTrailers(HeaderMap&) {
return FilterTrailersStatus::Continue;
}

void Filter::setDecoderFilterCallbacks(
Http::StreamDecoderFilterCallbacks& callbacks) {
decoder_callbacks_ = &callbacks;
}

} // namespace BackendAuth
} // namespace HttpFilters
} // namespace Extensions
Expand Down
11 changes: 2 additions & 9 deletions src/envoy/http/backend_auth/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,23 @@
#include "common/common/logger.h"
#include "envoy/http/filter.h"
#include "envoy/http/header_map.h"
#include "extensions/filters/http/common/pass_through_filter.h"
#include "src/envoy/http/backend_auth/filter_config.h"

namespace Envoy {
namespace Extensions {
namespace HttpFilters {
namespace BackendAuth {

class Filter : public Http::StreamDecoderFilter,
class Filter : public Http::PassThroughDecoderFilter,
public Logger::Loggable<Logger::Id::filter> {
public:
Filter(FilterConfigSharedPtr config) : config_(config) {}
~Filter() override = default;

// Http::StreamFilterBase
void onDestroy() override{};

// Http::StreamDecoderFilter
Http::FilterHeadersStatus decodeHeaders(Http::HeaderMap&, bool) override;
Http::FilterDataStatus decodeData(Buffer::Instance&, bool) override;
Http::FilterTrailersStatus decodeTrailers(Http::HeaderMap&) override;
void setDecoderFilterCallbacks(Http::StreamDecoderFilterCallbacks&) override;

private:
Http::StreamDecoderFilterCallbacks* decoder_callbacks_;
const FilterConfigSharedPtr config_;
};

Expand Down
1 change: 1 addition & 0 deletions src/envoy/http/backend_routing/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ envoy_cc_library(
"@envoy//source/common/http:headers_lib",
"@envoy//source/common/protobuf:utility_lib",
"@envoy//source/exe:envoy_common_lib",
"@envoy//source/extensions/filters/http/common:pass_through_filter_lib",
],
)

Expand Down
13 changes: 0 additions & 13 deletions src/envoy/http/backend_routing/filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,6 @@ FilterHeadersStatus Filter::decodeHeaders(HeaderMap& headers, bool) {
return FilterHeadersStatus::Continue;
}

FilterDataStatus Filter::decodeData(Buffer::Instance&, bool) {
return FilterDataStatus::Continue;
}

FilterTrailersStatus Filter::decodeTrailers(HeaderMap&) {
return FilterTrailersStatus::Continue;
}

void Filter::setDecoderFilterCallbacks(
Http::StreamDecoderFilterCallbacks& callbacks) {
decoder_callbacks_ = &callbacks;
}

} // namespace BackendRouting
} // namespace HttpFilters
} // namespace Extensions
Expand Down
12 changes: 2 additions & 10 deletions src/envoy/http/backend_routing/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,23 @@
#include "common/common/logger.h"
#include "envoy/http/filter.h"
#include "envoy/http/header_map.h"
#include "extensions/filters/http/common/pass_through_filter.h"
#include "src/envoy/http/backend_routing/filter_config.h"

namespace Envoy {
namespace Extensions {
namespace HttpFilters {
namespace BackendRouting {

class Filter : public Http::StreamDecoderFilter,
class Filter : public Http::PassThroughDecoderFilter,
public Logger::Loggable<Logger::Id::filter> {
public:
Filter(FilterConfigSharedPtr config);
~Filter() override = default;
;

// Http::StreamFilterBase
void onDestroy() override{};

// Http::StreamDecoderFilter
Http::FilterHeadersStatus decodeHeaders(Http::HeaderMap&, bool) override;
Http::FilterDataStatus decodeData(Buffer::Instance&, bool) override;
Http::FilterTrailersStatus decodeTrailers(Http::HeaderMap&) override;
void setDecoderFilterCallbacks(Http::StreamDecoderFilterCallbacks&) override;

private:
Http::StreamDecoderFilterCallbacks* decoder_callbacks_;
const FilterConfigSharedPtr config_;
absl::flat_hash_map<
std::string,
Expand Down
1 change: 1 addition & 0 deletions src/envoy/http/path_matcher/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ envoy_cc_library(
"//src/envoy/utils:http_header_utils_lib",
"@envoy//source/common/protobuf:utility_lib",
"@envoy//source/exe:envoy_common_lib",
"@envoy//source/extensions/filters/http/common:pass_through_filter_lib",
],
)

Expand Down
15 changes: 0 additions & 15 deletions src/envoy/http/path_matcher/filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ typedef ConstSingleton<RcDetailsValues> RcDetails;

} // namespace

void Filter::onDestroy() {}

Http::FilterHeadersStatus Filter::decodeHeaders(Http::HeaderMap& headers,
bool) {
std::string method(Utils::getRequestHTTPMethodWithOverride(
Expand Down Expand Up @@ -77,19 +75,6 @@ Http::FilterHeadersStatus Filter::decodeHeaders(Http::HeaderMap& headers,
return Http::FilterHeadersStatus::Continue;
}

Http::FilterDataStatus Filter::decodeData(Buffer::Instance&, bool) {
return Http::FilterDataStatus::Continue;
}

Http::FilterTrailersStatus Filter::decodeTrailers(Http::HeaderMap&) {
return Http::FilterTrailersStatus::Continue;
}

void Filter::setDecoderFilterCallbacks(
Http::StreamDecoderFilterCallbacks& callbacks) {
decoder_callbacks_ = &callbacks;
}

void Filter::rejectRequest(Http::Code code, absl::string_view error_msg) {
config_->stats().denied_.inc();

Expand Down
10 changes: 2 additions & 8 deletions src/envoy/http/path_matcher/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "common/common/logger.h"
#include "envoy/http/filter.h"
#include "envoy/http/header_map.h"
#include "extensions/filters/http/common/pass_through_filter.h"
#include "src/envoy/http/path_matcher/filter_config.h"

#include <string>
Expand All @@ -26,23 +27,16 @@ namespace Extensions {
namespace HttpFilters {
namespace PathMatcher {

class Filter : public Http::StreamDecoderFilter,
class Filter : public Http::PassThroughDecoderFilter,
public Logger::Loggable<Logger::Id::filter> {
public:
Filter(FilterConfigSharedPtr config) : config_(config) {}
~Filter() override = default;

void onDestroy() override;

Http::FilterHeadersStatus decodeHeaders(Http::HeaderMap&, bool) override;
Http::FilterDataStatus decodeData(Buffer::Instance&, bool) override;
Http::FilterTrailersStatus decodeTrailers(Http::HeaderMap&) override;
void setDecoderFilterCallbacks(Http::StreamDecoderFilterCallbacks&) override;

private:
void rejectRequest(Http::Code code, absl::string_view error_msg);

Http::StreamDecoderFilterCallbacks* decoder_callbacks_;
const FilterConfigSharedPtr config_;
};

Expand Down
1 change: 1 addition & 0 deletions src/envoy/http/service_control/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ envoy_cc_library(
"@envoy//source/common/grpc:status_lib",
"@envoy//source/common/http:headers_lib",
"@envoy//source/exe:envoy_common_lib",
"@envoy//source/extensions/filters/http/common:pass_through_filter_lib",
],
)

Expand Down
25 changes: 0 additions & 25 deletions src/envoy/http/service_control/filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,6 @@ Http::FilterTrailersStatus ServiceControlFilter::decodeTrailers(
return Http::FilterTrailersStatus::Continue;
}

void ServiceControlFilter::setDecoderFilterCallbacks(
Http::StreamDecoderFilterCallbacks& callbacks) {
decoder_callbacks_ = &callbacks;
}

Http::FilterHeadersStatus ServiceControlFilter::encode100ContinueHeaders(
Http::HeaderMap&) {
return Http::FilterHeadersStatus::Continue;
}

Http::FilterHeadersStatus ServiceControlFilter::encodeHeaders(
Http::HeaderMap& headers, bool) {
ENVOY_LOG(debug, "Called ServiceControl Filter : {} before", __func__);
Expand All @@ -148,21 +138,6 @@ Http::FilterDataStatus ServiceControlFilter::encodeData(Buffer::Instance& data,
return Http::FilterDataStatus::Continue;
}

Http::FilterTrailersStatus ServiceControlFilter::encodeTrailers(
Http::HeaderMap&) {
return Http::FilterTrailersStatus::Continue;
}

Http::FilterMetadataStatus ServiceControlFilter::encodeMetadata(
Http::MetadataMap&) {
return Http::FilterMetadataStatus::Continue;
}

void ServiceControlFilter::setEncoderFilterCallbacks(
Http::StreamEncoderFilterCallbacks& callbacks) {
encoder_callbacks_ = &callbacks;
}

void ServiceControlFilter::log(const Http::HeaderMap* request_headers,
const Http::HeaderMap* response_headers,
const Http::HeaderMap* response_trailers,
Expand Down
14 changes: 2 additions & 12 deletions src/envoy/http/service_control/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "envoy/access_log/access_log.h"
#include "envoy/http/filter.h"
#include "envoy/http/header_map.h"
#include "extensions/filters/http/common/pass_through_filter.h"
#include "src/envoy/http/service_control/filter_stats.h"
#include "src/envoy/http/service_control/handler.h"

Expand All @@ -29,7 +30,7 @@ namespace HttpFilters {
namespace ServiceControl {

// The Envoy filter for ESP V2 service control client.
class ServiceControlFilter : public Http::StreamFilter,
class ServiceControlFilter : public Http::PassThroughFilter,
public AccessLog::Instance,
public ServiceControlHandler::CheckDoneCallback,
public Logger::Loggable<Logger::Id::filter> {
Expand All @@ -46,20 +47,12 @@ class ServiceControlFilter : public Http::StreamFilter,
Http::FilterDataStatus decodeData(Buffer::Instance& data,
bool end_stream) override;
Http::FilterTrailersStatus decodeTrailers(Http::HeaderMap&) override;
void setDecoderFilterCallbacks(
Http::StreamDecoderFilterCallbacks& callbacks) override;

// Http::StreamEncoderFilter
Http::FilterHeadersStatus encode100ContinueHeaders(
Http::HeaderMap& headers) override;
Http::FilterHeadersStatus encodeHeaders(Http::HeaderMap& headers,
bool) override;
Http::FilterDataStatus encodeData(Buffer::Instance& data,
bool end_stream) override;
Http::FilterTrailersStatus encodeTrailers(Http::HeaderMap&) override;
Http::FilterMetadataStatus encodeMetadata(Http::MetadataMap&) override;
void setEncoderFilterCallbacks(
Http::StreamEncoderFilterCallbacks& callbacks) override;

// Called when the request is completed.
void log(const Http::HeaderMap* request_headers,
Expand All @@ -73,9 +66,6 @@ class ServiceControlFilter : public Http::StreamFilter,
private:
void rejectRequest(Http::Code code, absl::string_view error_msg);

// The callback funcion.
Http::StreamDecoderFilterCallbacks* decoder_callbacks_;
Http::StreamEncoderFilterCallbacks* encoder_callbacks_;
ServiceControlFilterStats& stats_;
const ServiceControlHandlerFactory& factory_;

Expand Down

0 comments on commit ca9ffa9

Please sign in to comment.