views:

31

answers:

1

When you're making a web app, you frequently need different things to happen at a given URL for HTTP POST requests than happen for HTTP GET requests. I am making a web app in Pylons, and I'm encountering this question.

Is it better to distinguish between POST and GET in my URL dispatcher (Routes) or in my controllers? What factors would make one of these options better than the other?

Would the answer be different if I were using Django? Rails? ASP.NET MVC?

+1  A: 

Good code should have clean separation of responsibility therefore the routing/dispatching code should control where I request is sent. This is just good design and shouldn't change because of the language.

A reader of the code can tell just from reading the routing code what is expected and where it will go. If you change your mind later on, you can changing the routing code without touching the controllers.

The controller is then only responsibile for handling the request which makes it simpler, making it easier to understand, have fewer bugs and easier to change.

Ben
That sounds very reasonable. Cheers.
Sean M