Skip to contents

Start the hotwater engine, launching a plumber API that is restarted whenever a file in the plumber API's folder is modified.

Extra directories can be specified to refresh the API when directories other than the plumber folder are modified.

If a plumber endpoint returns an HTML response, when hotwater refreshes the API, {hotwater} will also order a refresh of any webpage that is using the API.

Usage

run(path, dirs = NULL, port = NULL, host = NULL, ignore = NULL)

Arguments

path

path to plumber API file.

dirs

(optional) a character vector of extra directories to watch for file changes. Paths are resolved from the current working directory, not the directory of the plumber API file.

port

[default httpuv::randomPort()] port to launch API on.

port can either be set explicitly, or it defaults to the plumber.port option. If the plumber option is undefined, the fallback value of httpuv::randomPort() is used.

host

[default "127.0.0.1"] host to launch API on.

host can either be set explicitly, or it defaults to the plumber.host option. If the plumber option is undefined, the fallback value of "127.0.0.1" is used.

ignore

[default c("*.sqlite", "*.git*")] vector of file globs to ignore.

Details

To refresh the browser, a postserialize plumber::pr_hook is used to inject a websocket into the HTML client that listens for the plumber server refresh.

See also

Examples

if (FALSE) { # interactive()
 # start a hotwater session on port 9999
 hotwater::run(
   path = system.file("examples", "plumber.R", package = "hotwater"),
   port = 9999L
 )
}