ApiKeyExtractable class final

Extracts an API key from a header, falling back to the query string.

Machine-to-machine calls, and the one scheme where a key in the URL is still common — which is also why it ends up in access logs, proxy logs, and browser history. The header wins when both are present, and allowQuery turns the fallback off for a deployment that cannot afford it.

Implemented types

Constructors

ApiKeyExtractable({String header = 'x-api-key', String query = 'api_key', bool allowQuery = true})
Reads the key from header, or from the query parameter.
const

Properties

allowQuery bool
Whether a key in the query string is accepted at all.
final
hashCode int
The hash code for this object.
no setterinherited
The header carrying the key.
final
query String
The query parameter carrying the key, used only when allowQuery.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

extract(Request request) Future<Result<String, Rejection>>
Produces the value, or the rejection that stops the handler.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited