RESTful web services with complex actions (verbs)

I am trying to create a web application in which the back end is a full RESTful web service. That is, models (business logic) will be fully accessible through HTTP. For instance:

GET    /api/users/
GET    /api/users/1
POST   /api/users
PUT    /api/users/1
DELETE /api/users/1

What is the correct way to provide more methods that are not CRUD (verbs / actions)? Is it rather part of the RPC-api? How to properly design RPC api to run on top of a RESTful api?

For example, how would I elegantly implement a forgotten password method for a user.

POST (?) /api/users/1/forgot

The application (Controllers / View) will then use https requests (e.g. HMVC) to access models and methods. What would be better for authentication? OAuth, Basic Auth over HTTP?

Although this is the “best practice” for scalability later on, can I develop this task? Is it best to just follow a typical MVC model and provide a very simple API?

This question was mainly inspired by ASP.NET MVC 4 (WebAPI) and the NodeJS module https://github.com/marak/webservice.js

Thanks in advance

+3
source share
1 answer

I recently started learning REST, and when developing a new web service, I think you are doing the right thing to consider it.

. REST , -, . POST , imperative. , , , , - . I.e., , , , , , .

, - api . :

POST /users/1/remind HTTP/1.1
Host: api.myservice.example.com

REST . , , , . , . ( ): OAuth REST

: GET . RESTful, /users/ /users. URL-, . URL- . REST , - RESTful ( GET 200 OK), . URL-, , .:)

2: RESTful Web Services Richardson Ruby . - ?_method=remind. , , , , , GET, , . A GET , . . POST.

0

All Articles