HostnameRouter class

A utility that allows requests to be handled based on their origin's hostname.

For example, an application could handle example.com and api.example.com separately.

The provided patterns can be any Pattern. If a String is provided, a simple grammar (see HostnameSyntaxParser) is used to create RegExp.

For example:

  • example.com -> /example\.com/
  • *.example.com -> /([^$.]\.)?example\.com/
  • example.* -> /example\./[^$]*
  • example.+ -> /example\./[^$]+

Constructors

HostnameRouter({Map<Pattern, Angel> apps: const {}, Map<Pattern, FutureOr<Angel> Function()> creators: const {}})
HostnameRouter.configure(Map<Pattern, FutureOr<void> Function(Angel)> configurers, {Reflector reflector: const EmptyReflector(), AngelEnvironment environment: angelEnv, Logger logger, bool allowMethodOverrides: true, FutureOr<String> serializer(dynamic), ViewGenerator viewGenerator})
factory

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

handleRequest(RequestContext req, ResponseContext res) Future<bool>
Attempts to handle a request, according to its hostname. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

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