IoWebServerFactory class final

Creates the HTTP server the starter uses by default: dart:io's HttpServer, on the VM and in Flutter apps on mobile and desktop.

The starter declares one as the webServerFactory bean, with settings read from server.* and then passed to every WebServerFactoryCustomizer bean. Applications rarely touch it: they set properties, or change settings in a customizer. Import it from package:spring_boot_starter_web/io.dart to wrap it in a factory of your own, or to start a server outside the context, for example in a tool.

// A server for a test, on a free port, answering with a plain handler.
final server = IoWebServerFactory(const ServerProperties(port: 0))
    .getWebServer(FunctionHttpHandler(
      (request, response) => response.send(200, 'pong'),
    ));
await server.start();
log.info('listening on ${server.port}');

Spring Boot's default is Tomcat (TomcatServletWebServerFactory) in its place.

Implemented types

Constructors

IoWebServerFactory([ServerProperties settings = const ServerProperties()])
A factory whose servers use settings; Spring Boot's defaults when none are given (port 8080, all addresses).

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
settings ↔ ServerProperties
The settings the next server starts with; replace them with a changed copy (ServerProperties.copyWith).
getter/setter pairoverride

Methods

getWebServer(HttpHandler handler) → WebServer
A new, not yet started server that hands every request to handler.
override
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