It looks like you can't change your url pattern so one way would be to route to an action like bar::command which then calls the bar::check() or bar::confirm() actions depending on the value of the command parameter
Different controllers depending on GET parameter
-
31-05-2022 - |
Question
In mojolicious app I want define different controller action for url depend on get parameter.
In pseudocode it is:
#test.pl?command=check&id=1
$r->route('/test.pl?command=check')->via('GET')->to(controller => 'bar', action => 'check');
#test.pl?command=confirm&id=12&amount=100
$r->route('/test.pl?command=confirm')->via('GET')->to(controller => 'bar', action => 'confirm');
What I should use? Some kind of bridges? Help me with example please.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow