- Building RESTful Web services with Go
- Naren Yellavula
- 301字
- 2021-07-02 20:14:02
REST verbs and status codes
REST verbs specify an action to be performed on a specific resource or a collection of resources. When a request is made by the client, it should send this information in the HTTP request:
- REST verb
- Header information
- Body (optional)
As we mentioned previously, REST uses the URI to decode its resource to be handled. There are quite a few REST verbs available, but six of them are used frequently. They are as follows:
- GET
- POST
- PUT
- PATCH
- DELETE
- OPTIONS
If you are a software developer, you will be dealing with these six most of the time. The following table explains the operation, target resource, and what happens if the request succeeds or fails:

The numbers in the Success and Failure columns of the preceding table are HTTP status codes. Whenever a client initiates a REST operation, since REST is stateless, the client should know a way to find out whether the operation was successful or not. For that reason, HTTP has status codes for the response. REST defines the preceding status code types for a given operation. This means a REST API should strictly follow the preceding rules to achieve client-server communication.
All defined REST services have the following format. It consists of the host and API endpoint. The API endpoint is the URL path which is predefined by the server. Every REST request should hit that path.
A trivial REST API URI: http://HostName/API endpoint/Query(optional)
Let us look at all the verbs in more detail. The REST API design starts with the defining of operations and API endpoints. Before implementing the API, the design document should list all the endpoints for the given resources. In the following section, we carefully observe the REST API endpoints using PayPal's REST API as a use case.
- 物聯(lián)網(wǎng)標(biāo)準(zhǔn)化指南
- MERN Quick Start Guide
- Spring Boot 2.0 Projects
- 新一代物聯(lián)網(wǎng)架構(gòu)技術(shù):分層算力網(wǎng)絡(luò)
- Spring Cloud微服務(wù)架構(gòu)進(jìn)階
- 區(qū)塊鏈輕松上手:原理、源碼、搭建與應(yīng)用
- 網(wǎng)管員必讀:網(wǎng)絡(luò)管理(第2版)
- Building Web Applications with ArcGIS
- Getting Started with nopCommerce
- Professional Scala
- React Design Patterns and Best Practices(Second Edition)
- 想象的互動:網(wǎng)絡(luò)人際傳播中的印象形成
- 物聯(lián)網(wǎng)技術(shù)與實(shí)踐
- 通信系統(tǒng)實(shí)戰(zhàn)筆記:無處不在的信號處理
- 視聽變革:廣電的新媒體戰(zhàn)略