举个例子:Client-Server Communication
When you got to a bank, the bank teller acts as an intermediary or interface between you and the bank vault. And this is the same type of relationship we see in client-server communication: The user or client makes a request to the API server, which parses the requests, queries the database, formats a response and then sends it back.
Here is the process listed out:
- Client sends a request to the API server
- The API server parses that request
- Assuming the request is formatted correctly, the server queries the database for the information or performs the action in the request
- The server formats the response and sends it back to the client
- The client renders the response according to its implementation
如果上面的例子,很难理解,再提供一个例子
A customer talks to the waiter and tells the waiter what she wants. The waiter takes down the order and communicates it to the kitchen. The kitchen does their work, creating the food, and then the waiter delivers the order back to the customer.
In the metaphor, a customer is like a user, who tells the waiter what she wants. The waiter is like an API, receiving the customer’s order and training the order into easy-to-follow instructions that the kitchen then uses to fulfill that order - often following a specific set of codes, or input, that the kitchen easily recognizes. The kitchen is like a server that does the work of creating the order in the manner the customer wants it, hopefully! When the food is ready, the waiter picks up the order and delivers it to the customer.