DoxServer class

Constructors

DoxServer()
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
httpServer ↔ HttpServer
the http server, a NativeHttpServer (dox_http_native). Rust owns the sockets and parses HTTP. It has the dart:io HttpServer API.
getter/setter pair
responseHandler ↔ ResponseHandlerInterface?
set responseHandler
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

checkCertificate() → Future<void>
Stops the start when the files of AppConfig.tls, or of a port of AppConfig.ports, are bad: it throws a TlsException. Dox().startServer() runs it once, before any isolate starts. Else each isolate fails on its own and is started again, in a loop. It does nothing when no port has tls.
close({bool force = false}) → Future<void>
close http server
listen(int port, {Object? address, Function? onError, List<int> additionalPorts = const <int>[], List<PortConfig> ports = const <PortConfig>[]}) → Future<HttpServer>
listen the request. With no address it listens on all interfaces.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reloadCertificate() → Future<void>
Reads the certificate and key files of AppConfig.tls, and of each port of AppConfig.ports with tls, again, for example after certbot renewed them. New connections get the new certificate. Open connections keep the old one until they close. One call is enough: every isolate of the process gets it. When a file is bad, it throws a TlsException and the server keeps the old certificate. With more than one certificate, it checks all the files first, so a bad file changes no port. A file that changes between the check and the reload can still stop it half way: then call it again. It throws a StateError when no port has tls, before the server starts and after it is closed. Dox does not watch the files: the app decides when to call it (eg. on SIGHUP).
setResponseHandler(ResponseHandlerInterface? handler) → void
set response handler
shutdown(Duration timeout) → Future<void>
Graceful stop: no new connections, open requests get timeout to finish. Then every connection is closed.
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

checkPorts(int port, List<int> additional, List<PortConfig> ports) → void
Throws an ArgumentError when an app with ports lists a port two times, in port, additional and ports together. Such a port would be bound two times (the OS allows it), with two kinds of settings. Port 0 is a free port each time, so it can repeat. With no ports it checks nothing, as before AppConfig.ports. Dox().startServer() runs it once, before any isolate starts. Else each isolate fails on its own and is started again, in a loop.
hostFor(String? configured) → String?
The host to listen on: configured, else APP_HOST, else null (all interfaces).
portFor(int configured) → int
The port to listen on. APP_PORT in the env means configured (the app reads it into serverPort). With no APP_PORT, PORT wins: Cloud Run, Fly, Render and Heroku tell the app its port with it.