Skip to content

Server

[Source]

Runs an HTTP server.

Server operation

Information flow into the Server is as follows:

  1. Server listens for incoming TCP connections.

  2. _ServerConnHandler is the notification class for new connections. It creates a _ServerConnection actor and receives all the raw data from TCP. It uses the HTTP11RequestParser to assemble complete Request objects which are passed off to the _ServerConnection.

  3. The _ServerConnection actor deals with requests and their bodies that have been parsed by the HTTP11RequestParser. This is where requests get dispatched to the caller-provided Handler.

actor tag Server is
  _SessionRegistry tag

Implements

  • _SessionRegistry tag

Constructors

create

[Source]

Create a server bound to the given host and service. To do this we listen for incoming TCP connections, with a notification handler that will create a server session actor for each one.

new tag create(
  auth: TCPListenAuth val,
  notify: ServerNotify iso,
  handler: HandlerFactory val,
  config: ServerConfig val,
  sslctx: (SSLContext val | None val) = reference)
: Server tag^

Parameters

Returns


Public Behaviours

register_session

[Source]

be register_session(
  conn: _ServerConnection tag)

Parameters

  • conn: _ServerConnection tag

unregister_session

[Source]

be unregister_session(
  conn: _ServerConnection tag)

Parameters

  • conn: _ServerConnection tag

set_handler

[Source]

Replace the request handler.

be set_handler(
  handler: HandlerFactory val)

Parameters


dispose

[Source]

Shut down the server gracefully. To do this we have to eliminate any source of further inputs. So we stop listening for new incoming TCP connections, and close any that still exist.

be dispose()

Public Functions

local_address

[Source]

Returns the locally bound address.

fun box local_address()
: NetAddress val

Returns