Router.router path param is empty

Viewed 65

I have a API,created by val router = Router.router(vertx) router.patch("/api/v2/user/:userId/names")

if user id is not passed getting message - "error": "Page not found: /api/v2/user//names"

How can I give a default value if not passed or have another good idea?

1 Answers

You can't give a default value, you have to define another route.

val router = Router.router(vertx)
router.patch("/api/v2/user/names")
router.patch("/api/v2/user/:userId/names")

From a REST API design perspective, these are two different resources.

Related