in src/envoy/http/service_control/handler_utils.cc [305:336]
bool extractAPIKey(
const Envoy::Http::RequestHeaderMap& headers,
const ::google::protobuf::RepeatedPtrField<
::espv2::api::envoy::v12::http::service_control::ApiKeyLocation>&
locations,
std::string& api_key) {
// If checking multiple headers, cache the parameters so they are only parsed
// once
bool were_params_parsed{false};
Envoy::Http::Utility::QueryParamsMulti parsed_params;
for (const auto& location : locations) {
switch (location.key_case()) {
case ApiKeyLocation::kQuery:
if (extractAPIKeyFromQuery(headers, location.query(),
were_params_parsed, parsed_params, api_key))
return true;
break;
case ApiKeyLocation::kHeader:
if (extractAPIKeyFromHeader(headers, location.header(), api_key))
return true;
break;
case ApiKeyLocation::kCookie:
if (extractAPIKeyFromCookie(headers, location.cookie(), api_key))
return true;
break;
case ApiKeyLocation::KEY_NOT_SET:
break;
}
}
return false;
}