Interview -restful specification

# REST: representational state transfer (for Representational State Transfer)
# a RESTful specification: web Data Request Interface Design Specification
'' '
1) typically use https request
2) domain: There api keyword appears
 - https://api.example.com (cross-domain problems)
 - https://example.com/api
3) Version: different versions need to mark
 - https://example.com/api/v1 | - https://example.com/api/1
 - https://example.com/api/v2 | - HTTPS: / /example.com/api/2
4) resources: target data request is called resource, resources are generally nouns plural representation
 - https://example.com/api/v1/books (before non-standard cases: / get_books /)
5) mode of operation: no request from the link mode of operation reflect, decide on a request from the operation mode
 - get: https: //example.com/api/v1/books get all
 - post: https: / /example.com/api/v1/books new one
 - put: https: //example.com/api/v1/book/1 an update id = 1
 - patch: https: // example. com / api / v1 / book / 1 update an id = 1
 - delete: https: //example.com/api/v1/book/1 delete an id = 1
6) resource filter: passing parameters to filter the interface resources
 - https://example.com/api/v1/books?limit=10 limit 10
7) status code: standard status code to return data, by the data { "Status":} 200 is
 - sUCCESS ( "0", "query succeeds")
 - the NODATA ( "1xx", "incorrect, no data, displays basic information")
 - FEAILED ( "2xx", "query failure ")
8) an error message: request failed error message needs denoted {" message ":" invalid request parameter "}
9) result: the result of a successful return request operation {" results ": []}
 - GET: returns resource list | return a single resource
 - post: return a single additional resources
 - put: returns the resource update
 - patch: returns a resource update
 - delete: returns an empty document
10) returns the resource interface sub-resources: resources returned if there are sub-resource, returned sub-link address resources, such as finding cover picture book, the book can be expressed url
'' '

Guess you like

Origin www.cnblogs.com/fan-1994716/p/11881368.html