API网关只有一个端点吗?

发布于 2025-02-06 16:54:49 字数 201 浏览 1 评论 0原文

我正在学习有关微服务和API网关。一些文章提到API网关只有一个端点。那是对的吗?

假设我的电子商务页面拨打了2个呼叫, /产品和 /用户以获取产品和用户数据,它们分别在产品服务和用户服务中。

我的客户是否单独拨打api.com/products和api.com/users?还是它可以做api.com/exec?endpoint=users(或类似的东西)?

I’m learning about micro services and API gateways. Some articles mention that api gateways only have one endpoint. Is that correct?

Let’s say my e-commerce page makes 2 calls, /products and /users to get products and user data, and they are in a Product service and User service respectively.

Does my client make calls to api.com/products and api.com/users separately? Or does it do api.com/exec?endpoint=users (or something like this)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

在你怀里撒娇 2025-02-13 16:54:49

从上下文来看,这里的终点似乎是域-Api.com。该域内的特定URL,这是API网关所有者可以决定的东西。

通常,API有两种不同的方法。在您的示例中,有两种服务和一种向客户展示它们的方法是:

  • products.api.yourcompany.com
  • users.api.yourcompany.com

,每个服务都将拥有自己的端点(域),他们可以使用任何任何服务特定操作的URL格式;喜欢 /操作ABC或Exec?操作= ABC等。

第二种方法,这是API网关发光,这两个服务都可以隐藏在单端点后面:api.yourcompany.com-和API网关决定实际操作呼叫的外观。

From the context, it seems that the endpoint here is the domain - api.com. The specific url inside that domain, this is something for api gateway owners to decide on.

Typically there are two different approaches to api. In your example, there are two services and one way of exposing them to customers would be:

  • products.api.yourcompany.com
  • users.api.yourcompany.com

Clearly, each service would own its own endpoint (domain) and they can use any url format for specific operations; like /operationAbc or exec?operation=abc etc.

The second approach, and this is were api gateways shine, both services can be hidden behind single endpoint: api.yourcompany.com - and the api gateway decides how actual operation call looks like.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文