Fire: Fire Application

Description Super class Public fields Active bindings Methods

Description

Modified fiery::Fire class definition that includes some improvements:

Super class

fiery::Fire -> Fire

Public fields

path_extractor

function that transforms websocket to a path

Active bindings

url

Application URL

data

read application data

routers

read-only list of routers

handles

read-only list of handlers

statics

read-only list of statics

events

helpful guide to function arguments

sockets

read-only list of active websockets

Methods

Public methods

Inherited methods

Method trigger()

Triggers an event

Usage
Fire$trigger(event, ..., check = TRUE)
Arguments
event

(str) event name

...

(arg) args passed to handler

check

(flg) check whether this is protected


Method on_router()

Add a route

Usage
Fire$on_router(
  path,
  handler,
  ...,
  name = path,
  methods = "get",
  attach = c("request", "message", "header"),
  priority = 0L,
  replace = FALSE
)
Arguments
path

(str) endpoint

handler

(fun) handler; must have arguments request, response, keys, ....

...

(dta) extra metadata to identify this route.

name

(str) human-readable friendly name

methods

(chr) combination of GET, POST, PUT, PATCH, DELETE

attach

(str) event to attach. defaults to request.

priority

(int) relative positioning of the handler; lower will be executed first.

replace

(flg) whether or not to replace same name or error out


Method off_router()

Remove a route

Usage
Fire$off_router(name, attach = c("request", "message", "header"))
Arguments
name

(str) human-readable friendly name

attach

(str) event to attach. defaults to request.


Method on_static()

Add a static handler

Usage
Fire$on_static(
  path,
  file,
  name = path,
  index_html = TRUE,
  fallthrough = FALSE,
  html_charset = "utf-8",
  headers = list(),
  validation = character(0),
  replace = FALSE
)
Arguments
path

(url) URL path to serve

file

(pth) directory to serve on that path

name

(str) human-readable friendly name

index_html

(flg) whether or not to serve when index.html exists

fallthrough

(flg) if not available, use R callback

html_charset

(str) html charset, defaults to UTF-8

headers

(lst) headers that are included with the response

validation

(chr) character vector of headers needed

replace

(flg) if already exists, overwrite

...

(dta) extra metadata to identify this static path.


Method off_static()

Remove a static handler

Usage
Fire$off_static(name)
Arguments
name

(str) human-readable friendly name


Method build_routers()

Builds the route stack and attaches it as a plugin

Usage
Fire$build_routers(..., force = TRUE)
Arguments
...

(arg) extra arguments

force

(flg) force the attachment of the routes


Method attach()

This is a modified version of attach that returns the handler IDs associated, so that they can be removed later on.

Usage
Fire$attach(plugin, ..., force = FALSE)
Arguments
plugin

(ApplicationPlugin) to attach

...

(arg) passed to the plugin's on_attach() method

force

(flg) force attaching the plugin


Method detach()

Detaches a plugin

Usage
Fire$detach(name)
Arguments
name

(str) name of the plugin


Method detach_all()

Detaches all plugins

Usage
Fire$detach_all()

Method browse()

Browse to the App URL

Usage
Fire$browse()

Method clear_data()

Clear all data

Usage
Fire$clear_data()

Method clone()

The objects of this class are cloneable with this method.

Usage
Fire$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


tjpalanca/webtools documentation built on Dec. 23, 2021, 11 a.m.