_camelize in Routes

9 views
Skip to first unread message

Alvar Freude

unread,
Aug 6, 2013, 8:19:55 AM8/6/13
to perl...@googlegroups.com
Hi,

the sub _camelize in Kelp::Routes lowers and camelizes all destination packages in routes.

With this it is not possible to have a package names "(MyApp::)SuperDuper->sub" or "(MyApp::)REST::Something->sub".

I think it would be better to omit the "lc" in Kelp::Routes:

https://github.com/naturalist/kelp/blob/master/lib/Kelp/Routes.pm#L32


Or maybe I am missing something?


Ciao
Alvar

signature.asc

Stefan Geneshky

unread,
Aug 6, 2013, 3:04:59 PM8/6/13
to perl...@googlegroups.com
Camelization of the routes is a concept I borrowed from Mojolicious. The idea was to use shorter syntax to describe the route destinations. For example:

bar#foo becomes Bar::Foo
bar_foo#baz becomes BarFoo::baz

In your example above, SuperDuper::sub will become super_duper#sub.

Camelization of routes only occurs on routes that need it, i.e those that have a '#' sign in them. In my experience, camelization doesn't make writing routes easier. As a matter of a fact, it often makes them harder to read. Because of that, I don't use it. I have kept it in Kelp, in order to make it easier for folks migrating from Mojolicious.

I recommend you to write your routes using regular Perl syntax. To use you example:

$r->add( '/something', 'REST::sub_something' )

Cheers,
Stefan


Alvar Freude

unread,
Aug 6, 2013, 4:20:50 PM8/6/13
to perl...@googlegroups.com
Hi,

Am 06.08.2013 um 21:04 schrieb Stefan Geneshky <stefa...@gmail.com>:

> I recommend you to write your routes using regular Perl syntax. To use you example:
>
> $r->add( '/something', 'REST::sub_something' )

aah, thank you, I didn't realize that this will do it too!
Yes, this looks much better! :)

Parts of my App are called "DHZK" (Deluxe Homepage Zerbastel Kit) for historical reasons ...

Ciao
Alvar

signature.asc
Reply all
Reply to author
Forward
0 new messages