Give me a example of non-RESTful design?

前端 未结 4 1641
悲&欢浪女
悲&欢浪女 2021-02-19 05:18

I learned the term \"RESTful\" as a Rails developer. After reading wikipedia, also here and here.

I don\'t get it. It seems to me, Rails is only using a concise<

4条回答
  •  旧时难觅i
    2021-02-19 06:06

    A GET request should be idempotent and the request should not leave any side-effects on the server. Quoting from the HTTP spec sec 9.1.1:

    In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. These methods ought to be considered "safe". This allows user agents to represent other methods, such as POST, PUT and DELETE, in a special way, so that the user is made aware of the fact that a possibly unsafe action is being requested.

    Therefore GET /delete?student_id=3 already violates the idempotency assumption of the GET verb, since it will delete a record on the server.

    A RESTful interface is a uniform interface, which in other words means that a GET is supposed to behave as required by the HTTP spec. And this is what the spec says:

    The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. If the Request-URI refers to a data-producing process, it is the produced data which shall be returned as the entity in the response and not the source text of the process, unless that text happens to be the output of the process.

    ...

提交回复
热议问题