HTTPServerActor¶
Trait for actors that serve HTTP connections.
Extends TCPConnectionActor (for lori ASIO plumbing) and
HTTPServerLifecycleEventReceiver (for HTTP-level callbacks). The
actor stores an HTTPServer as a field and implements
_http_connection() to return it. All other required methods have
default implementations that delegate to the protocol.
Minimal implementation:
actor MyServer is HTTPServerActor
var _http: HTTPServer = HTTPServer.none()
new create(auth: lori.TCPServerAuth, fd: U32,
config: ServerConfig)
=>
_http = HTTPServer(auth, fd, this, config)
fun ref _http_connection(): HTTPServer => _http
fun ref on_request_complete(request': Request val,
responder: Responder)
=>
// build and send response using request' and responder
For HTTPS, use HTTPServer.ssl(auth, ssl_ctx, fd, this, config)
instead of HTTPServer(auth, fd, this, config).
The none() default ensures all fields are initialized before the
constructor body runs, so this is ref when passed to
HTTPServer.create() or HTTPServer.ssl().
Implements¶
Public Behaviours¶
dispose¶
Public Functions¶
on_request¶
Parameters¶
Returns¶
- None val
on_body_chunk¶
Parameters¶
Returns¶
- None val
on_request_complete¶
Parameters¶
Returns¶
- None val
on_closed¶
Returns¶
- None val
on_throttled¶
Returns¶
- None val
on_chunk_sent¶
Parameters¶
- token: ChunkSendToken val
Returns¶
- None val
on_unthrottled¶
Returns¶
- None val