The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
firesale is a plugin for fiery that provides a (potentially persistent) data store based on path parameters and client id.
It builds upon the storr package and thus provides a multitude of storage backends to suit your need while providing the same interface for your server logic.
# You can install marquee from CRAN
::pak("firesale")
pak
# Or get the development version from Github
::pak("thomasp85/firesale") pak
Using firesale is quite simple. You initialise the plugin and then attach it to your fiery server:
library(firesale)
<- FireSale$new(storr::driver_environment())
ds
ds#> <FireSale plugin (environment)>
Once created you attach it like any other plugin
<- fiery::Fire$new()
app
$attach(ds)
app
app#> 🔥 A fiery webserver
#> 🔥 💥 💥 💥
#> 🔥 Running on: 127.0.0.1:8080
#> 🔥 Plugins attached: firesale
#> 🔥 Event handlers added
#> 🔥 before-request: 1
Now, your request handlers will have access to a
datastore
element in their arg_list
argument
which will grant you access to the datastore. The datastore
will itself contain two elements: global
and
session
. The former gives access to a datastore shared by
all sessions, while the latter is scoped to the session of the request
being handled
$on("request", function(request, response, arg_list, ...) {
app$status <- 200L
response
# Use `session` to see if this is the first time
if (!isFALSE(arg_list$datastore$session$first)) {
# Store number of unique visitors in `global`
$datastore$global$count <- (arg_list$datastore$global$count %||% 0) + 1
arg_list
$body <- paste0(
response"This is your first visit\n",
"You are visiter number ",
$datastore$global$count
arg_list
)$datastore$session$first <- FALSE
arg_listelse {
} $body <- "You've been here before"
response
} })
As can be seen, the datastore
and its element are
list-like and you can treat session
and global
pretty much how you would a normal list in terms of getting and setting
values.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.