Should get '/projects/' => also handle /projects redirecting to /projects/
I am learning Flask, microframework in Python similar to Dancer. In flask if you define a route to something with a trailing slash like get '/projects/' => sub {} It will automatically insert a route for get '/projects' => sub { redirect '/projects/' } See Unique URLs / Redirection Behavior http://flask.pocoo.org/docs/0.10/quickstart/ Then if you manually try to add the slash-less route, Flask blows up. I wonder if Dancer2 should have similar behavior, without the blowing up part? Gabor
On Feb 3, 2015, at 5:52 AM, Gabor Szabo <gabor@szabgab.com> wrote:
I wonder if Dancer2 should have similar behavior, without the blowing up part?
In v1 at least, Dancer treats a URL with a trailing slash as different from one that lacks a trailing slash. If you want Dancer to respond to both, you either have to define a route handler for each separately, or you have to resort to trickery: https://www.mail-archive.com/dancer-users@dancer.pm/msg01115.html This is broken, IMHO, as it violates the expectations of anyone coming from a world where URL components are matched the same way as static files. That is to say: http://example.com/foo and http://example.com/foo/ will both serve $DocumentRoot/foo/index.{html,php,asp,whatever}.
On Tue, Feb 3, 2015 at 2:50 PM, Warren Young <wyml@etr-usa.com> wrote:
This is broken, IMHO, as it violates the expectations of anyone coming from a world where URL components are matched the same way as static files. That is to say:
and
will both serve $DocumentRoot/foo/index.{html,php,asp,whatever}.
No, typically the former will just redirect to the latter. If you don't, the base url for relative links will be wrong. That's why Gabor is IIUC suggesting doing the redirect automatically (I would hope with a way to override it).
On Feb 3, 2015, at 5:09 PM, Yitzchak Scott-Thoennes <sthoenna@gmail.com> wrote:
On Tue, Feb 3, 2015 at 2:50 PM, Warren Young <wyml@etr-usa.com> wrote:
This is broken, IMHO, as it violates the expectations of anyone coming from a world where URL components are matched the same way as static files. That is to say:
and
will both serve $DocumentRoot/foo/index.{html,php,asp,whatever}.
No, typically the former will just redirect to the latter.
Yes, I realize that. My point is that most dynamic web generation systems (ASP, PHP, JSP…) don’t let you serve different content from these two URLs. One is quietly mapped to the other, so that you can enter either into your browser and get the same effect. By not doing this silent automatic transform, Dancer is at least violating the Principle of Least Surprise, if not actual standards.
participants (3)
-
Gabor Szabo -
Warren Young -
Yitzchak Scott-Thoennes