Skip to content

make per_filter_config specific configs work automatically for filters #10164

Open

Description

@rgs1

Currently filter writers need additional plumbing to allow their filter to do per vhost/route overrides. E.g.:

// Fetch the virtual host specific config.
const VHostSpecificFilterConfig* Filter::getSpecificConfig() const {
  if (!decoder_callbacks_->route() || !decoder_callbacks_->route()->routeEntry()) {
    return nullptr;
  }

  const auto* entry = decoder_callbacks_->route()->routeEntry();
  const auto* settings = entry->virtualHost().perFilterConfig("pinterest.my_filter");

  if (settings != nullptr) {
    auto* vhost_config = dynamic_cast<const VHostSpecificFilterConfig*>(settings);
    return vhost_config;
  }

  return nullptr;
}

and then you have to merge that, with the config object you got from the Filter Factory. It's not that much logic, but it's a bit of hassle to a) do it for every filter and b) remember that you have to do it.

Thoughts on providing some plumbing to avoid repeating the above pattern (or thoughts on the general future of per vhost/route config overrides)?

cc: @mattklein123 @htuch @fishcakez

Activity

  1. dio commented on Feb 26, 2020

    @dio
    Member

    Seems very useful.

  2. added
    enhancement
    on Feb 26, 2020
  3. mattklein123 commented on Feb 26, 2020

    @mattklein123
    Member

    Agreed, IMO this could be part of the filter callback API and/or the route API.

  4. yuval-k commented on Apr 20, 2020

    @yuval-k
    Contributor

    @rgs1 When I made some changes to ext_authz, I wrote a utility that does some of that for you:

    const ConfigType* resolveMostSpecificPerFilterConfig(const std::string& filter_name,

    and

    getMergedPerFilterConfig(const std::string& filter_name, const Router::RouteConstSharedPtr& route,

  5. rgs1 commented on Apr 20, 2020

    @rgs1
    MemberAuthor

    @yuval-k ah nice, I did some of that manually for #10766. I'll follow-up with another PR to use those methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/httpenhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions