A `Beakr` object defines a web server instance using the [`httpuv`] package. It provides the main entry point for creating and starting a Beakr application, wrapping a [`Router`] and exposing lifecycle methods.

Format

An [`R6::R6Class`] generator for `Beakr` objects.

See also

[Router], [Middleware], [httpuv::startServer], [httpuv::runServer]

Public fields

name

Application name. If `NULL`, a random name is set in `$initialize()`.

router

The `Router` instance used to handle requests.

server

The underlying `httpuv` server object (once started).

Methods


Method appDefinition()

Build the application definition passed to **httpuv** (request & WS handlers).

Usage

Beakr$appDefinition()


Method new()

Initialize the app: create a `Router` and assign a random `name` if missing.

Usage

Beakr$new()


Method start()

Start the HTTP server via **httpuv**.

Usage

Beakr$start(host, port, daemon)

Arguments

host

Hostname or IP to bind.

port

Integer port to listen on.

daemon

If `TRUE`, run in background with `httpuv::startServer()`; otherwise run foreground with `httpuv::runServer()`.


Method print()

Print a one-line summary (name, state, host, port, #middlewares).

Usage

Beakr$print()


Method clone()

The objects of this class are cloneable with this method.

Usage

Beakr$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.