R/Static.R

Static <- setRefClass(
    'Static',
    'contains' = 'Middleware',
    fields = c('urls','file_server'),
    methods = list(
	initialize = function(urls=c(),root=pwd(),...){
	    urls <<- paste('^',urls,sep='')
	    file_server <<- Rook::File$new(root)
	    callSuper(...)
	},
	call = function(env){
	    path <- env[["PATH_INFO"]]
	    if (any(sapply(urls,function(i)length(grep(i,path))>0)))
		file_server$call(env)
	    else
		app$call(env)
	}
    )
)

Try the Rook package in your browser

Any scripts or data that you put into this service are public.

Rook documentation built on Nov. 10, 2022, 6:13 p.m.