1 // 2 // Copyright 2020 gRPC authors. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 #include <grpc/support/port_platform.h> 18 19 #include "absl/strings/string_view.h" 20 21 #include "src/core/lib/channel/channel_args.h" 22 23 // Channel arg key for the authority override. 24 #define GRPC_ARG_AUTHORITY_OVERRIDE "grpc.authority_override" 25 26 namespace grpc_core { 27 CreateAuthorityOverrideChannelArg(const char * authority)28grpc_arg CreateAuthorityOverrideChannelArg(const char* authority) { 29 return grpc_channel_arg_string_create( 30 const_cast<char*>(GRPC_ARG_AUTHORITY_OVERRIDE), 31 const_cast<char*>(authority)); 32 } 33 FindAuthorityOverrideInArgs(const grpc_channel_args * args)34absl::string_view FindAuthorityOverrideInArgs(const grpc_channel_args* args) { 35 const char* found = 36 grpc_channel_args_find_string(args, GRPC_ARG_AUTHORITY_OVERRIDE); 37 return found == nullptr ? "" : found; 38 } 39 40 } // namespace grpc_core 41