bearerToken extracts the API key from the `Authorization: Bearer ` handshake header (scheme match is case-insensitive per RFC 7235). Returns "" when the header is absent or not a Bearer credential.
(r *http.Request)
| 131 | // handshake header (scheme match is case-insensitive per RFC 7235). Returns "" |
| 132 | // when the header is absent or not a Bearer credential. |
| 133 | func bearerToken(r *http.Request) string { |
| 134 | h := r.Header.Get("Authorization") |
| 135 | const prefix = "Bearer " |
| 136 | if len(h) < len(prefix) || !strings.EqualFold(h[:len(prefix)], prefix) { |
| 137 | return "" |
| 138 | } |
| 139 | return strings.TrimSpace(h[len(prefix):]) |
| 140 | } |
| 141 | |
| 142 | // drainUnread sends notifications for all unread messages. Notifications are |
| 143 | // best-effort; messages are marked read only when fetched via the REST API. |