of static method

Authorization? of(
  1. Request request
)

Reads the header of request, or null when there is none.

Implementation

static Authorization? of(Request request) {
  final raw = RequestParts.of(request).headers['authorization'];
  if (raw == null) return null;

  final separator = raw.indexOf(' ');
  if (separator < 1) return Authorization(raw.toLowerCase(), '');
  return Authorization(
    raw.substring(0, separator).toLowerCase(),
    raw.substring(separator + 1).trim(),
  );
}