A
A
Alexey Volegov2014-12-11 12:27:06
RESTful API
Alexey Volegov, 2014-12-11 12:27:06

RESTful API and the Reality of Statelessness?

One of the limitations of the RESTful API is Statelessness. In all the examples I read, it looks like "Do not remember the state of the device." Is it so? And how then to store information about the device?
I will give an example from my practice. I need to authorize the device, give it a token and save some data about the device (device id, push token).
Now I am performing authorization and saving information about the device in the session. In fact, my token is session_id. In this session, I store user_id + device_id.
Am I doing the right thing with the RESTful API, or is there a more beautiful and correct approach?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Egor Kazantsev, 2014-12-11
@EagleMoor

"Statelessness" - Cheerful translation =) The meaning is this: the absence of a state (stateless). That is, requests are getting information depending on the PASSED parameters, the server between requests does not store anything and does not know anything about previous requests. The server should not care about everything except where to get the parameters from. But since REST began to be used to obtain information by specific users, I had to add an access_token. It sort of serves as an authorization - but I would call it "setting environment variables". We got a token - we found the "environment" specifically deployed the user, and the user has his own variables and rights there - and everyone is happy. In general, once it works, do not touch it. You think REST came from a good life - it seems to me that SOAP is just hard.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question