【问题标题】:Should I include a slash before a query for my WebAPI endpoint?我应该在查询我的 WebAPI 端点之前添加一个斜杠吗?
【发布时间】:2020-08-01 02:02:35
【问题描述】:

我正在为我的应用创建 API 端点。以下哪种端点格式更“标准”?在下面的示例中,我将从用户表中返回用户 ID 'john'。

https://localhost:33170/api/users?id=john

https://localhost:33170/api/users/?id=john

仅供参考,以下端点将返回所有用户:

https://localhost:33170/api/users

【问题讨论】:

    标签: api rest restful-url webapi


    【解决方案1】:

    已确定it doesn't matter if the trailing slash is on or not

    我不知道有哪个框架会区别对待这两种情况...这两条路线在我曾经使用过的每个框架中都是相同的。

    【讨论】:

      猜你喜欢
      • 2019-03-17
      • 2017-11-30
      • 1970-01-01
      • 2017-05-12
      • 2010-12-09
      • 1970-01-01
      • 2017-05-22
      • 2013-12-25
      • 1970-01-01
      相关资源
      最近更新 更多