syntax = "proto3";

package envoy.extensions.filters.http.header_mutation.v3;

import "envoy/config/common/mutation_rules/v3/mutation_rules.proto";
import "envoy/config/core/v3/base.proto";

import "udpa/annotations/status.proto";

option java_package = "io.envoyproxy.envoy.extensions.filters.http.header_mutation.v3";
option java_outer_classname = "HeaderMutationProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/header_mutation/v3;header_mutationv3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: Header mutation filter configuration]
// [#extension: envoy.filters.http.header_mutation]

message Mutations {
  // The request mutations are applied before the request is forwarded to the upstream cluster.
  repeated config.common.mutation_rules.v3.HeaderMutation request_mutations = 1;

  // The ``path`` header query parameter mutations are applied after ``request_mutations`` and before the request
  // is forwarded to the next filter in the filter chain.
  repeated config.core.v3.KeyValueMutation query_parameter_mutations = 3;

  // The response mutations are applied before the response is sent to the downstream client.
  repeated config.common.mutation_rules.v3.HeaderMutation response_mutations = 2;
}

// Per route configuration for the header mutation filter.
message HeaderMutationPerRoute {
  Mutations mutations = 1;
}

// Configuration for the header mutation filter. The mutation rules in the filter configuration will
// always be applied first and then the per-route mutation rules, if both are specified.
message HeaderMutation {
  Mutations mutations = 1;

  // If per route HeaderMutationPerRoute config is configured at multiple route levels, header mutations
  // at all specified levels are evaluated. By default, the order is from most specific (i.e. route entry level)
  // to least specific (i.e. route configuration level). Later header mutations may override earlier mutations.
  //
  // This order can be reversed by setting this field to true. In other words, most specific level mutation
  // is evaluated last.
  bool most_specific_header_mutations_wins = 2;
}
