超薄3 - 如何添加或选择路线?

时间:2016-03-30 09:45:49

标签: routes slim slim-3

我如何在Slim 3 routes中拥有or-option?

例如,这就是我目前所做的事情:

(gdb)
(gdb) source pythonstart.py
Python 2.7.6 (default, Jun 22 2015, 18:00:18)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> 
>>> exit()
(gdb)        <---- Pressing Enter here
Python 2.7.6 (default, Jun 22 2015, 18:00:18)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> 

而不是重复这些代码的块,我可以把它们变成像:

// Home page.
$app->get('/', function (Request $request, Response $response, array $args) {
    // Get the application settings.
    $settings = $this->get('settings');

    // Check if the home page class is provided.
    ... lots of codes
});

$app->get('/home', function (Request $request, Response $response, array $args) {
    // Get the application settings.
    $settings = $this->get('settings');

    // Check if the home page class is provided.
    ... lots of codes
});

1 个答案:

答案 0 :(得分:1)

Optional segments正是您要找的。