rest - How to maintain state in a Restful service -


below sequence of events in crud web service trying create

step 1: user request post /shape/trycreate (try-create request)

step 2:controller method receives object :trycreate(shape s)

step 3: service method returns matching shapes: collection<shape> trycreate(shape s)

step 4: if duplicate shape exists throws exception , exceptionmapper returns failure response

if returned collection empty create shape , return success response

else if return object containing paths view shapes match shape user trying create extent , return object contains continue path still create shape

so response object contains paths view/shape/id001 view/shape/id003 view/shape/id007 shapes shape s user create , has continue path create/shape/some-token

here think can use some-token --> shape object map on server side entry lives 5 minutes or so. using can validate user has not sent direct request create has gone through step trycreate->view matching shapes-> still create doesn't have again send details of shape in create request sent in trycreate request.

now problem using expiring cache on server side store validated tokens isn't restful design. q1)**how should ensure not direct request create , follows trycreate request **q2) resend details of shape in create request otherwise how achieve this?

thanks

i believe token approach mentioned ok. http request not stateful, business logic on service side that. creating entity , requesting it, 2 http request not stateful, if have created entity in fetch request, otherwise not.

can naming endpoints, how about:

1) post /shape/request

2) post /shape/process

the 2nd valid restful request described in this book, terming controller resource.

by say, contrary heading, this explains relation rest , statelessness.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -