Skip to content

Mounted routers should require a slash for route location #476

@blairj09

Description

@blairj09

On MacOS 10.14.16 with R 3.6.1 and Plumber 0.4.6, mounted routers are inaccessible. Consider the following example:

library(plumber)

root <- plumber$new()

# Mount first
first <- plumber$new()
first$handle("GET", "/echo", function(msg = "") {
  list(msg = paste0("The message is '", msg, "'"))
})
root$mount("first", first)

# Mount second
second <- plumber$new()
second$handle("GET", "/add", function(x, y) {
  as.numeric(x) + as.numeric(y)
})
root$mount("second", second)

root
#> # Plumber router with 0 endpoints, 4 filters, and 2 sub-routers.
#> # Call run() on this object to start the API.
#> ├──[queryString]
#> ├──[postBody]
#> ├──[cookieParser]
#> ├──[sharedSecret]
#> ├──/first
#> │  │ # Plumber router with 1 endpoint, 4 filters, and 0 sub-routers.
#> │  ├──[queryString]
#> │  ├──[postBody]
#> │  ├──[cookieParser]
#> │  ├──[sharedSecret]
#> │  └──/echo (GET)
#> ├──/second
#> │  │ # Plumber router with 1 endpoint, 4 filters, and 0 sub-routers.
#> │  ├──[queryString]
#> │  ├──[postBody]
#> │  ├──[cookieParser]
#> │  ├──[sharedSecret]
#> │  └──/add (GET)

This seems to indicate that echo would be available at /first/echo and add would be available at /second/add. However, when trying to access either of those endpoints, a 404 error is returned:

curl -X GET 'http://localhost:5762/first/echo?msg=hi'
{"error":["404 - Resource Not Found"]}
curl -X GET 'http://localhost:5762/second/add?x=1&y=9'
{"error":["404 - Resource Not Found"]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty: advancedBest for maintainers to addresseffort: low< 1 day of workpriority: lowLow-impact bug, docs polish, papercut, or unclear low-severity request.type: enhancementAdds a new, backwards-compatible feature

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions