ServerUniverseNative class

Server application class

This is the core of the server application. Generally you would create one for each app.

Inheritance
Available extensions

Constructors

ServerUniverseNative({String pathPrefix = "", ServerUniverseLogType serverUniverseLogType = ServerUniverseLogType.info, ServerUniversePlatformType serverUniversePlatformType = ServerUniversePlatformType.io, int simultaneousProcessing = 1000000000, FutureOr onNotFound(HttpRequest req, HttpResponse res)?, FutureOr onError(HttpRequest req, HttpResponse res, Object error, StackTrace stackTrace)?})
Creates a new ServerUniverseNative application.

Properties

app ServerUniverseNative
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
logWriter ↔ void Function(dynamic messageFn(), ServerUniverseLogType type)
Writer to handle internal logging.
getter/setter pair
onError FutureOr Function(HttpRequest req, HttpResponse res, Object error, StackTrace stackTrace)?
Optional handler for when the server throws an unhandled error
getter/setter pair
onNotFound FutureOr Function(HttpRequest req, HttpResponse res)?
Optional handler for when a route is not found
getter/setter pair
pathPrefix String
getter/setter pairinherited
requestQueue ↔ Queue
Incoming request queue
getter/setter pair
routes List<HttpRoute>
List of routes
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
server HttpServer?
HttpServer instance from the dart:io library
getter/setter pair
serverUniverseLogType ServerUniverseLogType
finalinherited
serverUniversePlatformType ServerUniversePlatformType
finalinherited
simultaneousProcessing int
getter/setter pairinherited
typeHandlers List<TypeHandler>
An array of TypeHandler that ServerUniverseNative walks through in order to determine if it can handle a value returned from a route.
getter/setter pair

Methods

addRoute(HttpRoute route) → void
all(String path, FutureOr callback(HttpRequest req, HttpResponse res), {List<FutureOr Function(HttpRequest req, HttpResponse res)> middleware = const []}) HttpRoute
Create a route that listens on all methods
close({bool force = true}) Future<void>
Close the server and clean up any resources
createRoute(ServerUniverseMethodType method, String path, FutureOr callback(HttpRequest req, HttpResponse res), [List<FutureOr Function(HttpRequest req, HttpResponse res)> middleware = const []]) HttpRoute
delete(String path, FutureOr callback(HttpRequest req, HttpResponse res), {List<FutureOr Function(HttpRequest req, HttpResponse res)> middleware = const []}) HttpRoute
Create a delete route
ensureInitialized() FutureOr<void>
inherited
get(String path, FutureOr callback(HttpRequest req, HttpResponse res), {List<FutureOr Function(HttpRequest req, HttpResponse res)> middleware = const []}) HttpRoute
Create a get route
Create a head route
listen({int port = 3000, dynamic bindIp = '0.0.0.0', bool shared = true, int backlog = 0}) Future<HttpServer>
Call this function to fire off the server.
override
listenSecure({required SecurityContext securityContext, int port = 3000, dynamic bindIp = '0.0.0.0', bool shared = true, int backlog = 0}) Future<HttpServer>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
options(String path, FutureOr callback(HttpRequest req, HttpResponse res), {List<FutureOr Function(HttpRequest req, HttpResponse res)> middleware = const []}) HttpRoute
Create an options route
parsePattern(String path) String
inherited
patch(String path, FutureOr callback(HttpRequest req, HttpResponse res), {List<FutureOr Function(HttpRequest req, HttpResponse res)> middleware = const []}) HttpRoute
Create a patch route
post(String path, FutureOr callback(HttpRequest req, HttpResponse res), {List<FutureOr Function(HttpRequest req, HttpResponse res)> middleware = const []}) HttpRoute
Create a post route
printRoutes() → void
Print out the registered routes to the console
put(String path, FutureOr callback(HttpRequest req, HttpResponse res), {List<FutureOr Function(HttpRequest req, HttpResponse res)> middleware = const []}) HttpRoute
Create a put route
registerOnDoneListener(void listener(HttpRequest, HttpResponse)) Function
Register a listener when a request is complete
removeOnDoneListener(Function listener) → void
Dispose of any on done listeners when you are done with them.
tcpSocket({required FutureOr<ServerUniverseTcpSocketConnection> onTcpSocket()}) → void
toString() String
A string representation of this object.
inherited
websocket({required String path, required FutureOr<ServerUniverseWebSocketConnection> onWebSocket()}) HttpRoute

Operators

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