将REST API放在子域或子文件夹中更好吗?

编程入门 行业动态 更新时间:2024-10-28 02:34:16
本文介绍了将REST API放在子域或子文件夹中更好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们有一个Web应用程序,其中包含URL example 。现在我们想要扩展这个应用程序的一部分作为一个宁静的服务,我们正在讨论最好的URL模式。我搜索过,但找不到任何具体的指导。

We have a web application which is hosted with the URL example. Now we want to extend a part of this application as a restful service, and we are debating on the best URL pattern. I searched, but could not find any concrete guidance.

我们是否应该使用网址格式 api.example 或 exaple/api/v1 ?

Should we have the URL pattern api.example or exaple/api/v1?

这是否有任何标准指导?

Is there any standard guidance for this?

推荐答案

取决于根据您的需求。

如果您使用 http://api.example 它使您的API成为子域名。基本上,如果您的REST服务要由多个客户端使用,则此URL模式很好,但如果只有一个客户端连接到您的API,那么模式 example/api/v1 很好。但是,如果您想添加更多API并连接更多客户端,则最好使用 http://示例。 COM / API / V1 。例如,请考虑以下事项。

If you use api.example it makes your API a subdomain. Basically, this URL pattern is good if your REST service is to be consumed by multiple clients, but if only one client is connected to your API then the pattern example/api/v1 is good. However, if you want to add more API with more clients connected to it it’s better to use example/api/v1. For example, consider the following.

example/reportapi/apioperation?parameters example/paymentapi/apioperation?parameters example/searchapi/apioperation?parameters

最后但并非最不重要的是,PayPal使用的模式是 http:/ /example/api/v1 。

Last but not least, PayPal uses the pattern example/api/v1.

更多推荐

将REST API放在子域或子文件夹中更好吗?

本文发布于:2023-11-14 16:47:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587998.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:放在   文件   夹中   REST   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!