如何定义使用相同匿名回调的多个路由?
$app->get('/first_route',function()
{
//Do stuff
});
$app->get('/second_route',function()
{
//Do same stuff
});
我知道我可以使用对可以工作的函数的引用,但我更喜欢使用匿名函数的解决方案以与代码库的其余部分保持一致。
所以基本上,我正在寻找的是一种做这样的事情的方法:
$app->get(['/first_route','/second_route'],function()
{
//Do same stuff for both routes
});
〜或〜
$app->get('/first_route',function() use($app)
{
$app->get('/second_route');//Without redirect
});
谢谢你。