Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make direct_response exception free #38141

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions source/extensions/filters/network/direct_response/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@ namespace DirectResponse {
* Config registration for the direct response filter. @see NamedNetworkFilterConfigFactory.
*/
class DirectResponseConfigFactory
: public Common::FactoryBase<envoy::extensions::filters::network::direct_response::v3::Config> {
: public Common::ExceptionFreeFactoryBase<
envoy::extensions::filters::network::direct_response::v3::Config> {
public:
DirectResponseConfigFactory() : FactoryBase(NetworkFilterNames::get().DirectResponse) {}
DirectResponseConfigFactory()
: ExceptionFreeFactoryBase(NetworkFilterNames::get().DirectResponse) {}

private:
Network::FilterFactoryCb createFilterFactoryFromProtoTyped(
absl::StatusOr<Network::FilterFactoryCb> createFilterFactoryFromProtoTyped(
const envoy::extensions::filters::network::direct_response::v3::Config& config,
Server::Configuration::FactoryContext& context) override {
auto content = THROW_OR_RETURN_VALUE(
Config::DataSource::read(config.response(), true, context.serverFactoryContext().api()),
std::string);

return [content](Network::FilterManager& filter_manager) -> void {
filter_manager.addReadFilter(std::make_shared<DirectResponseFilter>(content));
};
absl::StatusOr<std::string> content_or =
Config::DataSource::read(config.response(), true, context.serverFactoryContext().api());
RETURN_IF_NOT_OK_REF(content_or.status());
return
[content = std::move(content_or.value())](Network::FilterManager& filter_manager) -> void {
filter_manager.addReadFilter(std::make_shared<DirectResponseFilter>(content));
};
}

bool isTerminalFilterByProtoTyped(
Expand Down
1 change: 0 additions & 1 deletion tools/code_format/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ paths:
- source/extensions/filters/network/ext_authz
- source/extensions/filters/network/mongo_proxy
- source/extensions/filters/network/thrift_proxy
- source/extensions/filters/network/direct_response
- source/extensions/filters/network/generic_proxy
- source/extensions/filters/network/ratelimit
- source/extensions/filters/common
Expand Down