Is That REST API Really RPC? Roy Fielding Seems to Think So

前端 未结 9 2495
日久生厌
日久生厌 2020-12-02 04:00

A large amount of what I thought I knew about REST is apparently wrong - and I\'m not alone. This question has a long lead-in, but it seems to be necessary because the infor

相关标签:
9条回答
  • 2020-12-02 04:59

    I think over the number of years that REST has been out there now, technologists have come to terms with the concept of a Resource and what really is or isn't RESTful.

    According to the Richardson Maturity Model, there are 4 levels (0-3) that define how RESTful your API is, with 3 meaning a truly RESTful API, just as Roy Fielding intended it to be.

    Level 0 is when you have one entry point URI - like SOAP.

    Level 1 means the API is able to distinguish between different resources, and has more than one entry points - still smells of SOAP.

    Level 2 is when you use HTTP verbs - GET, POST, DELETE primarily. This is the level at which REST really comes into picture.

    At Level 3, you start using hypermedia controls to make your API truly RESTful.

    Suggested links for further reading:

    • What is the Richardson Maturity Model?
    • Martin Fowler's blog: Richardson Maturity Model
    0 讨论(0)
  • 2020-12-02 05:00

    I have been looking for a good example of an API written following the HATEOAS and had trouble finding one (I found both the SunCloud API and AtomPub stuff difficult to apply to a "normal" API situation). So I tried making a realistic example on my blog that followed Roy Fieldings advice on what it means to be a proper REST implementation. I found it very difficult to come up with the example, despite the fact that it is fairly simple in principle (just confusing when working with an API as opposed to a webpage). I get what Roy was taking issue with and agree, it is just a shift in mindset to implement properly for an API.

    Have a look: API Example using Rest

    0 讨论(0)
  • 2020-12-02 05:06

    Let's assume GET /foos/createForm is invoked to get form fields values for which must be provided when we go to create POST /foos . Now this particular URL i.e the 1 used to create foos should be mentioned within the response for GET /foos/createForm as a submit action link according to Fielding's proposition, right ?
    Then what is the benefit of mapping actions to well-known Http verbs to actions, "convention over code/config" thing is nullified.

    0 讨论(0)
提交回复
热议问题