parseAuthHeaderName function

String? parseAuthHeaderName(
  1. Object? value,
  2. String where
)

Parses the optional authHeader: yaml value into a header name. Null stays null (the Authorization: Bearer default); anything that is not a non-empty RFC 7230 token throws ConfigException naming where — the config entry that owns the value.

Implementation

String? parseAuthHeaderName(Object? value, String where) {
  if (value == null) return null;
  final name = value is String ? value.trim() : '';
  if (!_authHeaderNamePattern.hasMatch(name)) {
    throw ConfigException(
      '$where: invalid authHeader "$value" — expected an HTTP header name '
      "(letters, digits, !#\$%&*+-.^_`|~), e.g. x-api-key",
    );
  }
  return name;
}