mardi 24 février 2015

Is this pattern RESTful? Or something else?


I'm working on a new project that will create a web-based API to perform CRUD operations on a relational database.


Originally, I was going to create the API as http-based, and make it RESTful so that - for example - operations on a person record might look like:



PUT /api/person/create/Sally/Smith/ssmith@acmeco.com


or



GET /api/person/findByEmail/ssmith@acmeco.com


For Create and Read.


However, I've since swapped out the http layer (node/express) for an http/ websockets layer (node/express.io). I've created realtime routes so that now, once a client has an open socket connection, they could perform the same actions as above with:



socket.emit('person:create', {firstname: 'Sally', lastname: 'Smith', email: 'ssmith@acmeco.com'});


and



socket.emit('person:select', {email: 'ssmith@acmeco.com'});


In one sense, this kinda sorta meets the constraints of REST (it is client/server, it is "stateless" in that no request relies on a prior request, etc.) but it feels like calling this pattern "RESTful" is wrong.


Is it? If it's not REST, what is it?





Aucun commentaire:

Enregistrer un commentaire