【发布时间】:2020-01-01 08:00:34
【问题描述】:
我正在使用 Restify 创建 REST API。我以 /ConfigDetails/:name/:id 格式创建了路由,其中 name 和 id 是可选的。
If none of the two params is given, all configdetails will be fetched;
If name is given, config details for that name will be returned;
If id is given, config details for that id will be returned;
我的问题是,如何使它们成为可选的?使用我定义的当前路由,除非所有两个参数都存在,否则它将无法解析并会落入默认路由。 根据我的理解,restify 不支持“?” 谁能帮我解决这个问题。
【问题讨论】: