什么是endpoint

5,947 阅读1分钟

最近接触到一个新的概念:endpoint, 是以为记

what is endpoint:

An endpoint is the 'connection point' of a service, tool, or application accessed over a network. In the world of software, any software application that is running and "listening" for connections uses an endpoint as the "front door." When you want to connect to the application/service/tool to exchange data you connect to its endpoint.

Simply put, an endpoint is one end of a communication channel. When an API interacts with another system, the touchpoints of this communication are considered endpoints. For APIs, an endpoint can include a URL of a server or service. Each endpoint is the location from which APIs can access the resources they need to carry out their function.
APIs work using ‘requests’ and ‘responses.’ When an API requests information from a web application or web server, it will receive a response. The place that APIs send requests and where the resource lives, is called an endpoint.

example

endpointRESTful 风格下通常看起来是这样:

/this-is-an-endpoint
/another/endpoint
/some/other/endpoint 
/login
/accounts
/cart/items

放在某个域名下:

https://example.com/this-is-an-endpoint
https://example.com/another/endpoint
https://example.com/some/other/endpoint
https://example.com/login
https://example.com/accounts
https://example.com/cart/items

http 或者 https 都可以,这里只是用 http 举例。

HTTP method不同,endpoint看起来也不一样, 比如说:

GET /item/{id}
PUT /item/{id}

这是两个不同的 endpoints, 一个是用于 CRUDR (Retrieving), 一个是用于 CRUDU (updating)