router.router路径参数为空

发布于 2025-01-26 17:11:51 字数 169 浏览 2 评论 0原文

我有一个API,由 val Router = Router.Router(vertx)创建 router.patch(“/api/v2/user/:userId/names”)

未传递用户ID获取消息 - “错误”:

如果 如果不通过或有另一个好主意,则默认值?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画尸师 2025-02-02 17:11:51

您不能给出默认值,必须定义另一个路线。

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

从REST API设计的角度来看,这是两个不同的资源。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文