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, the default), or the server of the ServerAdapter of startServer(server:). All have 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({ServerAdapter? server}) → 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, and for a CustomServer.
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>[], ServerAdapter? server}) → 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 Properties

adapter ↔ ServerAdapter
The server work of this isolate: the adapter of the type of the server. listen sets it, before the first request. Before that (eg. a request object in a unit test) it is the native one.
getter/setter pair
setsLength → bool
true when a response may set its content length: the server does not gzip (a server gzips only when no length is set). listen sets it from the server, so the autoCompress of a binder counts too. Before that (a unit test): from compress of the config.
no setter

Static Methods

checkBinder(ServerAdapter? server, AppConfig config) → void
Throws an ArgumentError when server is a CustomServer and config asks for tls or http2, on the main port or on a port of AppConfig.ports. Its binder sets them on its own server. It also throws for BuiltInServer.ioHttpServer with http2: dart:io has no HTTP/2.
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).
isTls(HttpServer server) → bool
true when server speaks HTTPS
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.