diff --git a/R/parse-block.R b/R/parse-block.R index a7ab30e5c..f5d2b0fdc 100644 --- a/R/parse-block.R +++ b/R/parse-block.R @@ -227,6 +227,7 @@ activateBlock <- function(srcref, file, expr, envir, addEndpoint, addFilter, mou stopOnLine(lineNum, file[lineNum], "A single function can only be a filter, an API endpoint, or an asset (@filter AND @get, @post, @assets, etc.)") } + # ALL if statements possibilities must eventually call eval(expr, envir) if (!is.null(block$paths)){ lapply(block$paths, function(p){ ep <- PlumberEndpoint$new(p$verb, p$path, expr, envir, block$serializer, srcref, block$params, block$comments, block$responses, block$tags) @@ -253,6 +254,7 @@ activateBlock <- function(srcref, file, expr, envir, addEndpoint, addFilter, mou } else if (!is.null(block$filter)){ filter <- PlumberFilter$new(block$filter, expr, envir, block$serializer, srcref) addFilter(filter) + } else if (!is.null(block$assets)){ path <- block$assets$path @@ -263,5 +265,9 @@ activateBlock <- function(srcref, file, expr, envir, addEndpoint, addFilter, mou stat <- PlumberStatic$new(block$assets$dir, expr) mount(path, stat) + + } else { + + eval(expr, envir) } } diff --git a/R/plumber.R b/R/plumber.R index 5edd5592b..ede549cfe 100644 --- a/R/plumber.R +++ b/R/plumber.R @@ -179,9 +179,6 @@ plumber <- R6Class( if (!is.null(file)){ private$lines <- readUTF8(file) private$parsed <- parseUTF8(file) - # populate the local envir with parameters defined within the file - # https://github.com/trestletech/plumber/issues/329 - sourceUTF8(file, private$envir) for (i in 1:length(private$parsed)){ e <- private$parsed[i]