Mojolicious: getting rid of waypoints
By Abhijit Menon-Sen <email@example.com>
I have been less active than usual for several weeks due to poor health,
and it came as a surprise to discover that Mojolicious 2.82 deprecated
waypoints, a feature that I used in more than one app. I couldn't find
any explanation of the reasons for the change (the commit message says
only "deprecated waypoint support in Mojolicious"), hence this note.
Waypoints were earlier considered for removal because they were poorly
understood, but were retained because sensible uses of them were found
in the wild at the time. This time, they were deprecated because their
special-case handling was in conflict with providing more control over
format detection, and because their lack could be worked around easily.
Unfortunately, subsequent changes (after the deprecation) seem to have
broken waypoints, which I discovered when going from 2.6x to 2.9x in a
single step. I chose to get rid of my waypoints rather than investigate
the problem more closely (because I suspected that the "fix" would break
It's easy to rewrite code that uses waypoints. Here's an example from
one of my apps:
The above code can be written as:
my $logs = $internal->route('/logs');
Depending on the situation, other alternatives may be available. For
example, you could just as easily declare one route for /logs, and
another for /logs/tail.
It's an easy workaround, with only minor disadvantages. If you use the
nested routes, you need a new temporary variable ($logs). If you declare
separate routes, you have to repeat the prefix unnecessarily. But that's
a small price to pay.
I was worried about the breakage at first, but Sebastian points out that
nobody else has complained in the month since the change. Given that few
people ever understood or used waypoints, perhaps nobody was affected.