resthub / springmvc-router

Adds route mapping capacity to any "Spring MVC based" webapp. Uses playframework.org Router implementation.
http://resthub.github.com/springmvc-router/
Other
167 stars 63 forks source link

Case-insensitivity to match a controller #10

Closed electrotype closed 12 years ago

electrotype commented 12 years ago

I'm trying to implement a "default" route like this:

* /{controller}/{action} {controller}.{action}

Let's say I have a TestController#helloWorld() action, it seems the only way to call it is by lowercasing the first letter of the controller but not the other characters of that token:

/testController/helloWorld

This won't work:

/testcontroller/helloworld

It is sad, because when I reverse-route it, using Router.reverse("testController.helloWorld"), I get it all lowercased and it doesn't work:

/testcontroller/helloworld

Only the controller token seems to be case-sensitive (with the first character lowercased). The "action" part seems case-insensitive, "/testController/HELLOworld" works..

It would be very nice if the routing system was able to match a controller in a case-insensitive manner, or at least using all lowercased characters!

bclozel commented 12 years ago

Done. Merged in master. Latest SNAPSHOT updated.

One thing though; I think Play 1.2.x uses Controller names starting with a capital letter. It has a meaning: Controllers are called statically (all actions methods are static in Play's controllers).

In Spring MVC, Controllers are beans (instances) and actions are not static. That's why your route file should use bean names (which happen to be lowercased class names by default) - but you actually can define custom Controller names (using bean annotations).

Maybe it's something that should be made clear in the documentation.

electrotype commented 12 years ago

Wow, that was quick.. Thanks!

I now fully understand the casing of the controller tokens, that makes perfect sense!