Three stages of Buyonline RESTful

We are redesigning our buyonline functionality and we are doing it in a RESTful way.

This is a three-step process and the customer is prompted to enter data at each step.

Let's say three urls:

/step1.aspx

/step2.aspx

/step3.aspx

Each step is fairly self-contained and does not require data from any of the other steps.

The question is how to stop clients from going directly to step2 w / out by first filling out the details in step 1 if each step doesn't know anything about the previous step?

I know I can add a property to my object model, telling me which step was the last, etc., but doesn't that violate the whole REST principle?

I also don't want to check my model to see if the data in the previous step was files, because that again violates REST principles.

I think I am gradually moving away from the concept I need (something) to tell me where I have been, but I don’t want to.

Should / Could the controller possibly detect that the story doesn't contain a previous step setting control back to where I think it should be?

+1


source to share


2 answers


REST URLs must represent objects. e.g. books / orders / photos, etc.

I think the confusion above is that you are trying to represent the booking sequence in REST terms as entities, and (of course) they are not. Thus, objects that your customers can select, their orders, etc., can usefully be presented in this way. Other elements of the process should not be.



You could argue that step 1 is an address (for an argument). But the POST of the address object is different from entering that data in a form and allowing navigation to / from linked pages. This operation has a sequence or flow to it and is conceptually richer than just POSTING / GETING / DELETEing addresses. You illustrated this by arguing that you want someone not to complete step 2 without completing step 1, etc.

+3


source


When going from step1.asx to step2.asx, pass a request parameter containing some key that tells the server that step1 has been visited. For example, does step1.asx have an href for step2.asx? Whatever = a92jv29.

"a92jv29" could be, for example, an encrypted timestamp from a server. You can easily verify that it is valid (not expired, not in the future) on the server side. There is no need to save state.



Your URL might have better names like "terms.aspx", "registration.aspx" or whatever, but this is not strictly necessary.

+2


source







All Articles