StreamServer class abstract
Stream server.
##Start a server serving static resources only
new StreamServer().start();
##Start a full-featured server
new StreamServer(uriMapping: { //URI mapping
"/your-uri-in-regex": yourHandler
}, errorMapping: { //Error mapping
"404": "/webapp/404.html",
"500": your500Handler,
"yourLib.YourSecurityException": yourSecurityHandler
}, filterMapping: {
"/your-uri-in-regex": yourFilter
}).start();
)
Constructors
-
StreamServer({Map<
String, dynamic> ? uriMapping, Map<int, dynamic> ? errorMapping, Map<String, RequestFilter> ? filterMapping, String? homeDir, bool disableLog = false}) -
Constructor.
*
factory
- StreamServer.router(Router router, {String? homeDir, bool disableLog = false})
-
Constructs a server with the given router.
factory
Properties
-
channels
→ List<
HttpChannel> -
Returns a readonly list of channels served by this server.
no setter
- connectionCount → int
-
The number of active connections.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- homeDir → String
-
The path of the home directory. It is the directory that static resources
no setter
-
indexNames
→ List<
String> -
A list of names that will be used to locate the resource if
no setter
- isRunning → bool
-
Indicates whether the server is running.
no setter
- logger → Logger
-
The logger for logging information.
no setter
- pathPreprocessor ↔ PathPreprocessor?
-
Preprocessor that will be used to preprocess the path of each request,
getter/setter pair
- resourceLoader → ResourceLoader
-
The resource loader used to load the static resources.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sessionTimeout ↔ int
-
The timeout, in seconds, for sessions of this server.
Default: 1200 (unit: seconds)
getter/setter pair
- shallCount ← bool Function(HttpConnect connect)
-
A callback to control whether to increase connectionCount.
no getter
- uriVersionPrefix ↔ String
-
The prefix used to denote a different version of JavaScript or Dart code,
getter/setter pair
- version → String
-
The version.
no setter
Methods
-
filter(
String uri, RequestFilter filter, {bool preceding = false}) → void - Maps the given URI to the given filter. *
-
forward(
HttpConnect connect, String uri, {HttpRequest? request, HttpResponse? response}) → Future -
Forward the given
connect
to the givenuri
. * -
include(
HttpConnect connect, String uri, {HttpRequest? request, HttpResponse? response}) → Future -
Includes the given
uri
. * -
map(
String uri, dynamic handler, {bool preceding = false}) → void - Maps the given URI to the given handler. *
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onError(
void onError(HttpConnect? connect, dynamic error, StackTrace? stackTrace)?) → void - The application-specific error handler to listen all uncaught errors
-
onIdle(
void onIdle()) → void - Specifies a callback called when the server is idle, i.e.,
-
start(
{dynamic address, int port = 8080, int backlog = 0, bool v6Only = false, bool zoned = true}) → Future< HttpChannel> - Starts the server to handle the given channel. *
-
startOn(
ServerSocket socket, {bool zoned = true}) → HttpChannel - Starts the server to an existing socket. *
-
startSecure(
SecurityContext context, {dynamic address, int port = 8443, bool v6Only = false, bool requestClientCertificate = false, int backlog = 0, bool zoned = true}) → Future< HttpChannel> - Starts the server listening for HTTPS request. *
-
stop(
) → Future - Stops the server. It will close all channels. *
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited