In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
What is REST API? How does REST API work? These problems may be encountered in our daily work. Through these questions, I hope you can gain more. Here are the details of uncovering these problems.
First of all, understand that REST is an acronym for Representational State Transfer. Simply put, it is a Web application or mobile application, or a smartwatch, or any interface that uses data access.
When the client submits a request, a resource is obtained in this case, and the REST API receives the request, identifies the requested resource, finds out which data needs to be aggregated, what format, and data matching to create a format representing the request, including resource ID, Hyperlinks pointing to available actions, etc., responds to the response in the multimedia format and sends it back to the client. The client receives the data and parses it into meaningful content, while REST API waits for the next request.
Simply put, the client issues the request, and the REST API receives the request, collects and parses the data, and returns the data and response headers to the client.
To better understand REST, let's first break down the six constraints of REST:
1.Client-Server architecture, this constraint ensures that the client manages the user interface, while the server manages the data store, in short, we completely separate the content from its interaction.
Stateless, between requests, complement stores client context or information (that is, state) on the server, the client is responsible for tracking its own session state, and all requests sent from the client must be self-contained and complete. If the client's session state is relevant, its request must be sent together, if the server needs to store the state It must be passed to the database or similar service at a specific time. Cacheability, caching is a key part of Web architecture and performance optimization, and all REST responses must be clearly marked as cacheable or non-cacheable to ensure that the caching client works as expected. In a hierarchical system, the system must be designed so that the client cannot know whether it connects directly to the server or to an intermediary such as a mirror, which ensures scalability and contributes to security. On-demand coding allows the server to transfer executable code to the client in the form of client-side JavaScript and compiled components to extend and customize functionality, which is a less common use of REST. Unified interface, must use resource identification in the request, in the REST system on Web, URI is used to send the request, the URI will specify the resource it is looking for, the key here is the data on the server, REST returns a representation of the resource, it can have a different format from the server resource, so, although the resource data can be stored in my SQL as a table, the return may be JSON or XML set HTML Next, once the client has a representation of the resource, it can also modify or delete the resource. Third, the unified interface must publish description information, which is suitable for sending and receiving REST data. If JSON is received, the media type of the response information will be set to JSON. Without this information, the data cannot be parsed reliably. Fourth, the unified interface must use hypermedia as the engine of application state, which is a complex saying that once the client accesses REST resources, it can discover all available resources and methods through improved hyperlinks.
In other words, the REST service describes its own use of each returned resource, and it can be considered a RESTful API if and only if the Web-based API satisfies these six constraints.
Now let's start with a basic Get request. An example of an Application/json format is as follows:
{
":"
}
Example: if you want to send a Https get request method for Azure Resource Manager provider using a request header field similar to the following
GET / subscriptions?api-version=2014-04-01-preview HTTP/1.1
Authorization: Bearer
Host: management.azure.com
After reading the above, do you have any further understanding of REST API? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel. Thank you for reading.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.