简体   繁体   English

为什么要使用点符号api端点?

[英]why use dot notation api endpoints?

I'm currently looking at the api for slack and some other apps and I'm seeing that they are using a . 我目前正在查看slack和其他一些应用程序的api,并且看到它们正在使用. in their api endpoints . 在他们的api端点中 Is there a reason or benefit using the . 使用该工具有理由或好处吗. notation in stead of / ? 表示法代替/

Example: https://slack.com/api/chat.update 示例: https://slack.com/api/chat.updatehttps://slack.com/api/chat.update

There is no intrinsic benefit of one over the other. 彼此之间没有内在的好处。 You could equally ask why most APIs use / , in stead of end points like http://example.com/grandparent.parent.child?modifier 您可能同样会问,为什么大多数API都使用/来代替诸如http://example.com/grandparent.parent.child?modifier类的端点?

The most obvious reason for the existence of a path like this in the past, was file system mapping. 过去存在这样的路径的最明显原因是文件系统映射。 Maybe there was a chat.update.cgi script handling the request. 也许有一个chat.update.cgi脚本处理了请求。 Those sorts of limitations no longer apply however. 但是,这些限制不再适用。

Also, it seems redundant to have /api/ in the path. 另外,在路径中包含/ api /似乎是多余的。 I would be wary of using such systems. 我会警惕使用这样的系统。 Their authors would seem to have forgotten that your whole website is your API regardless of whether the representations are HTML or JSON. 他们的作者似乎忘记了整个网站就是您的API,无论这些表示形式是HTML还是JSON。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM