Rserve.http.add.static.Rd
Rserve.http.add.static
installs a new static handler to be used by the
HTTP/HTTPS servers. It will trigger only if the path prefix matches prefix
and will map the subsequent portion of the path in the request URL to a file
system location specified by path
. If the resulting item in the file system
is a directory, then index
(if set) will be appended to the path and served
instead (if it is a file).
Rserve.http.rm.all.statics
removes all static handlers from the current
R session.
Rserve.http.add.static(prefix, path, index = NULL, last = FALSE)
Rserve.http.rm.all.statics()
string, path prefix for which this handler will be used
string, path in the filesystem used as root to serve the content
optional string, will be appended to the file system path if
the target is a directory (typical value is "index.html"
).
logical, if FALSE
then processing continues to other handlers
if the target does not exist. If TRUE
then all requests for the prefix
will be handled only by this handler, possible resulting in "404 not found"
result if the reqeusted file does not exist.
The HTTP/HTTPS server supports both static and dynamic handlers. The typical use
is to invoke .http.request
function in R for dynamic handling, but it also
supports static maps of URL paths to file system locations. The static handlers
are checked first.
Rserve.http.add.static
installs a new static handler, adding it to the
list of handlers. The handlers are consulted in the order that they are added.
The static handler supports conditional GETs and relies on the file system modification times to determine if a file has been modified.
The return value is considered experimental and may change in the future: Integer, number of active handlers (which is the same as the index of this handler).
## standard handler serving all files in the current working directory
## and consults index.html in directories if no file is specified.
Rserve.http.add.static("/", getwd(), "index.html", TRUE)
#> [1] 1
## start the server with:
## run.Rserve(http.port=8080, qap=FALSE)