Alfred class

Server application class

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

Available Extensions

Constructors

Alfred({FutureOr onNotFound(HttpRequest req, HttpResponse res)?, FutureOr onInternalError(HttpRequest req, HttpResponse res)?, LogType logLevel = LogType.info, int simultaneousProcessing = 50})
Creates a new Alfred application.

Properties

hashCode int
The hash code for this object.
no setterinherited
logWriter ↔ void Function(dynamic messageFn(), LogType type)
Writer to handle internal logging.
getter/setter pair
onInternalError ↔ (FutureOr Function(HttpRequest req, HttpResponse res)?)
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
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
typeHandlers List<TypeHandler>
An array of TypeHandler that Alfred walks through in order to determine if it can handle a value returned from a route.
getter/setter pair

Methods

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
Close the server and clean up any resources
delete(String path, FutureOr callback(HttpRequest req, HttpResponse res), {List<FutureOr Function(HttpRequest req, HttpResponse res)> middleware = const []}) HttpRoute
Create a delete route
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.
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
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.
toString() String
A string representation of this object.
inherited

Operators

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