serve function
Future<RelicServer>
serve(
- Handler handler,
- InternetAddress address,
- int port, {
- SecurityContext? securityContext,
- int? backlog,
Starts a server that listens on the specified address
and
port
and sends requests to handler
.
If securityContext
is provided, a secure server will be started.
Every response will get a "date" header.
If this header is present in the Response
, it will not be
overwritten.
Implementation
Future<RelicServer> serve(
final Handler handler,
final InternetAddress address,
final int port, {
final SecurityContext? securityContext,
final int? backlog,
final bool shared = false,
}) async {
final adapter = IOAdapter(await bindHttpServer(
address,
port: port,
context: securityContext,
backlog: backlog ?? 0,
shared: shared,
));
final server = RelicServer(adapter);
await server.mountAndStart(handler);
return server;
}