[dancer-users] Help with a POST

Warren Young wyml at etr-usa.com
Mon Aug 10 19:54:26 BST 2015


On Aug 10, 2015, at 11:34 AM, Richard Reina <gatorreina at gmail.com> wrote:
> 
> noticed that he put a get sub then followed by a post sub for the same page.  Tried this and it worked and the form no longer puts the submited imput into the url which is my objective for using post.  I hope that's okay.

That’s not only okay, it’s exactly the right way to do it.

Think of the HTTP verb (GET, POST, PUT, DELETE...) as part of a sentence, with the URL being the object of that sentence.  You need both in order to make sense of the request.

The browser says GET.  Get what?  GET /app/foo/bar.  Okay, browser, here is /app/foo/bar.

The browser wants us to have some new data.  How does it tell us this?  With a POST.  What is it posting?  It is posting the data following the HTTP Content header.  Where does it want this new data to be?  Under /app/foo/bar.  Okay, browser, we accept your new data.

These are completely different uses of /app/foo/bar, because the verbs are different.

The same is true for the other HTTP verbs.  Dancer supports three more, via the del, put, and patch keywords.  These would all be different requests as well, even if the URL part remains the same.

I recommend that you read up on the REST design paradigm.  Route-based web frameworks (Dancer, node.js, etc.) make REST implementation straightforward, as compared to file-based web frameworks (ASP, PHP, Catalyst, etc.)


More information about the dancer-users mailing list