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.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

handleRequest(RequestContext req, ResponseContext res) Future<bool>
Attempts to handle a request, according to its hostname.
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