简体   繁体   中英

How to make REST requests more user friendly like RPC?

I've been highly considering creating a REST service rather than RPC but it seems to me that a client/user will have to write a significant amount of code to achieve the same thing compared with an RPC service. Moreover, implementing a REST service would require a user some basic knowledge about REST. To illustrate in PHP:

REST

  • To send GET, POST, PUT, DELETE request the user must send his request using CURL
  • Of course this requires his server to have CURL enabled, not good for some shared host
  • Aside from the data parameters the users needs to send, CURL requires additional lines of code to send the request.

RPC

  • To send a similar request with an RPC service, the user simply calls a URL together with data parameters. ie: example.com?foo=bar&baz=quz

Is there a way to make REST as "easy" as RPC. I'm thinking of encapsulating REST request with RPC methods but that breaks the whole idea isn't it?

REST does not force you to use GET, POST, PUT and DELETE. it just means that a single URL represents a single content. you can also implement a RESTful behaviour like this:

GET /index.php
GET /item.php?id=x
POST /create.php
POST /update.php
POST /delete.php

even create, update and delete could be done with get requests...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM