4

I am dealing with a large API and I'd like to distribute its definition over several file. As far as I understood, reading the documentation this where the "mounnt()" method from a plumb comes to play

I have tried the following:

iris.R:

#* Return a bit of iris
#* @get /iris
function(){
        head(iris)
}

In a new R session running:

irisAPI <- plumber::plumb("iris.R")
server <- plumber::plumber$new()
server$mount("/server", irisAPI)
server$run(host="0.0.0.0", port=8080, swagger= T)

Curling returns nothing, the swagger json is empty Cancelling and then running the exact same thing onthe irisAPI plumb and then it works.

Is this a bug or am I missing something?

Thanks,

Ylan
  • 69
  • 4
  • Where are you curling? Using your code, curling `localhost:8000/server/iris` gives me the head of iris. However, you are right, the swagger UI is empty, which is probably a bug. – asachet May 03 '19 at 15:52

1 Answers1

1

I had the same problem.

The problem was in plumber version. On CRAN repositories exist 0.4.6, you need download 0.5.0 (on docs say it but downloaded version is 0.4.7.9000) version from github using devtools library on R.

https://github.com/trestletech/plumber/blob/master/NEWS.md https://cran.r-project.org/web/packages/plumber/index.html

The follow code run succesfully for me:

root <- plumber$new()

a <- plumber$new("controllers/a.R")
root$mount("/a", a)

b <- plumber$new("controllers/b.R")
root$mount("/b", b)

root$run(port = 8080, swagger=TRUE, debug= TRUE)

Regards!

Juan
  • 83
  • 1
  • 8