VirtualHost abstract class
The VirtualHost class is a utility class for handling multiple hosts on multiple sources, by using a named-based approach.
abstract class VirtualHost {
/**
* Get the [Stream] of [HttpRequest]s, not matching any hosts. If unused, the
* default implementation will result in a [HttpHeaders.FORBIDDEN] response.
*/
Stream<HttpRequest> get unhandled;
/**
* Construct a new [VirtualHost].
*
* The optional [source] is a shortcut for calling [addSource].
*
* Example of usage:
*
* HttpServer.bind(..., 80).then((server) {
* var virtualHost = new VirtualHost(server);
* virtualServer.addHost('static.myserver.com')
* .listen(...);
* virtualServer.addHost('cache.myserver.com')
* .listen(...);
* })
*/
factory VirtualHost([Stream<HttpRequest> source]) => new _VirtualHost(source);
/**
* Provide another source of [HttpRequest]s in the form of a [Stream].
*/
void addSource(Stream<HttpRequest> source);
/**
* Add a host to the [VirtualHost] instance. The host can be either a specific
* domain (`my.domain.name`) or a wildcard-based domain name
* (`*.domain.name`). The former will only match the specific domain name
* while the latter will match any series of sub-domains.
*
* If both `my.domain.name` and `*.domain.name` is specified, the most
* qualified will take precedence, `my.domain.name` in this case.
*/
Stream<HttpRequest> addHost(String host);
}
Constructors
factory VirtualHost([Stream<HttpRequest> source]) #
Construct a new VirtualHost.
The optional source is a shortcut for calling addSource.
Example of usage:
HttpServer.bind(..., 80).then((server) {
var virtualHost = new VirtualHost(server);
virtualServer.addHost('static.myserver.com')
.listen(...);
virtualServer.addHost('cache.myserver.com')
.listen(...);
})
factory VirtualHost([Stream<HttpRequest> source]) => new _VirtualHost(source);
Properties
final Stream<HttpRequest> unhandled #
Get the Stream of HttpRequests, not matching any hosts. If unused, the
default implementation will result in a HttpHeaders.FORBIDDEN response.
Stream<HttpRequest> get unhandled;
Methods
abstract Stream<HttpRequest> addHost(String host) #
Add a host to the VirtualHost instance. The host can be either a specific
domain (my.domain.name) or a wildcard-based domain name
(*.domain.name). The former will only match the specific domain name
while the latter will match any series of sub-domains.
If both my.domain.name and *.domain.name is specified, the most
qualified will take precedence, my.domain.name in this case.
abstract void addSource(Stream<HttpRequest> source) #
Provide another source of HttpRequests in the form of a Stream.