IOS 8: "Go" restful programming best practices

Source: Internet
Author: User

Source Address: http://fann.im/blog/2013/07/15/best-practices-for-restful-api/

do server development, inevitably have external interface, just see Best practices for designing a pragmatic RESTful API, simply excerpt to make a note.

  1. API is to face the developer's UI, so be friendly to the developer, can be easily accessed in the browser input.
  2. Comply with WEB standards as much as possible.
  3. Use RESTful URLs. The URL identifies the resource, HTTP Method (get/post/put/delete) Operation controls the resource, where get gets, POST new, PUT update, delete delete, and a PATCH section update.
  4. URLs identify resources in complex form.
  5. URL Resource as an atomic operation.
  6. documentation, and with appropriate examples, it is best to provide examples of direct browser +curl.
  7. Once the API is determined it is not easy to modify, update and delete to have the corresponding document description.
  8. The API has to be versioned and displayed directly in the URL, for example /api/1/xyz .
  9. URLs can keep up with conditional filtering control parameters, such as /tickets?state=open .
  10. Wrap a common set of conditions into a URL resource, for example /tickets/recently_closed .
  11. The URL can contain a list of returned fields, returning only the contents of the specified field, such as/tickets?fields=id,subject
  12. Only the JSON format, and then there is no need to indicate the format suffix in the URL.
  13. The URL is named in Serpentine (underlined form), for example user_timeline .
  14. The API returns the Content-type to be set and the result is compressed with Gzip.
  15. RESTful GET is read only and does not allow data to be modified.
  16. API requests are limited in number of times, similar to Twitter rate limiting
  17. If necessary, use OAuth 2 authentication.
  18. The API header information contains cache information such as ETAG.
  19. Useful error message: Unique error code + error description information, with corresponding document.
  20. Take advantage of HTTP status code, such as 200/201/204/304/401/403/404/405.

IOS 8: "Go" restful programming best practices

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.