|
@@ -1,42 +0,0 @@
|
1
|
|
-function (file, dir = ".")
|
2
|
|
-{
|
3
|
|
- dirMode <- NULL
|
4
|
|
- if (!missing(file) && !missing(dir)) {
|
5
|
|
- stop("You must set either the file or the directory parameter, not both")
|
6
|
|
- }
|
7
|
|
- else if (missing(file)) {
|
8
|
|
- if (identical(dir, "")) {
|
9
|
|
- stop("You must specify either a file or directory parameter")
|
10
|
|
- }
|
11
|
|
- dirMode <- TRUE
|
12
|
|
- dir <- sub("/$", "", dir)
|
13
|
|
- file <- list.files(dir, "^plumber\\.r$", ignore.case = TRUE,
|
14
|
|
- full.names = TRUE)
|
15
|
|
- if (length(file) == 0) {
|
16
|
|
- stop("No plumber.R file found in the specified directory: ",
|
17
|
|
- dir)
|
18
|
|
- }
|
19
|
|
- }
|
20
|
|
- else {
|
21
|
|
- dirMode <- FALSE
|
22
|
|
- }
|
23
|
|
- entrypoint <- list.files(dir, "^entrypoint\\.r$", ignore.case = TRUE)
|
24
|
|
- if (dirMode && length(entrypoint) > 0) {
|
25
|
|
- old <- setwd(dir)
|
26
|
|
- on.exit(setwd(old))
|
27
|
|
- x <- source(entrypoint)
|
28
|
|
- pr <- x$value
|
29
|
|
- if (!("plumber" %in% class(pr))) {
|
30
|
|
- stop("entrypoint.R must return a runnable Plumber router.")
|
31
|
|
- }
|
32
|
|
- pr
|
33
|
|
- }
|
34
|
|
- else if (file.exists(file)) {
|
35
|
|
- plumber$new(file)
|
36
|
|
- }
|
37
|
|
- else {
|
38
|
|
- stop("File does not exist: ", file)
|
39
|
|
- }
|
40
|
|
-}
|
41
|
|
-<bytecode: 0x55df34386588>
|
42
|
|
-<environment: namespace:plumber>
|