RESTful design Style

Source: Internet
Author: User

See the following URLs for a simple overview and The use of front- end IOS

Http://www.ruanyifeng.com/blog/2011/09/restful.html

Http://www.cnblogs.com/artech/p/restful-web-api-02.html

First, the characteristics of RESTful

(1) resource specified by URI

(2) operations on resources, including acquisition, creation, modification, and deletion, correspond exactly to the get, POST, put, and Delete methods provided by the HTTP protocol

(3) manipulating resources through the representation of resources

(4) The expression of a resource can be Xml/html/json

Second, State transformation (Transfer)

Accessing a Web site represents an interactive process between the client and the server. In this process, data and state changes are bound to be involved.

The Internet Communication Protocol HTTP protocol is a stateless protocol. This means that all States are saved on the server side. Therefore, if the client wants to operate the server, there must be some way to make the server side "state Transfer". And this transformation is based on the expression layer, so is the "Expression Layer state transformation."

The method that the client uses, can only be the HTTP protocol. Specifically, there are four verbs in the HTTP protocol that represent the mode of operation: GET, POST, PUT, DELETE. They correspond to four basic operations: get is used to get a resource, post is used to create a new resource (and can also be used to update resources), put is used to update resources, and delete is used to delete resources.

Iii. examples

Iv. Development and use

// HttpMethod selection means to get, create, modify, and delete data that sends JSON to the server

Request. HttpMethod = @ "POST";

[Request setvalue:@ "Application/json" forhttpheaderfield:@ "Content-type"];

// serialized object

request. Httpbody = [nsjsonserialization datawithjsonobject: obj options:0 Error:NULL];

About serialization the next article will take the POST request as an example

RESTful design Style

Related Article

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.