serve function Null safety
- Handler handler,
- Object address,
- int port,
- {SecurityContext? securityContext,
- int? backlog,
Starts an HttpServer that listens on the specified address
and
port
and sends requests to handler
.
If a securityContext
is provided an HTTPS server will be started.
See the documentation for HttpServer.bind and HttpServer.bindSecure
for more details on address
, port
, backlog
, and shared
.
Implementation
Future<HttpServer> serve(
Handler handler,
Object address,
int port, {
SecurityContext? securityContext,
int? backlog,
bool shared = false,
}) async {
backlog ??= 0;
var server = await (securityContext == null
? HttpServer.bind(address, port, backlog: backlog, shared: shared)
: HttpServer.bindSecure(
address,
port,
securityContext,
backlog: backlog,
shared: shared,
));
serveRequests(server, handler);
return server;
}