Api Url 部件命名法

Api Url Parts Nomenclature

我有一个 api 喜欢

http://api.mycompany.com/products/bycategory/{category_id}

结尾部分/products/bycategory/{category_id}是如何命名的?如果我删除域部分,如果我把它放在 web.config 中,我该如何命名其余部分?

URI?我看了一些文章,但我很困惑。有时完整的 Url 似乎是 URI 其他提到的剩余部分。

谢谢。

一个URL由这些部分组成:

  • 协议,例如,http://
  • 域,例如,api.mycompany.com
  • 路径,例如,/products/bycategory/{category_id}
  • 可能是查询字符串,例如 ?key=value&otherKey=otherValue

如何解释路径和查询字符串取决于服务器。一个简单的网络服务器可能只提供路径指向的文件。应用程序服务器可能会将路径解释为查询。

REST resource naming guide talks about "resources" which makes sense since first a URL is-a uniform resource identifier (URI)。 URI 还使用术语 "path".

参见 this question on REST API naming guidelines 及其答案,那里使用的术语也是 "path"。

我也会使用 "path"。