| Conditions | 2 |
| Paths | 1 |
| Total Lines | 28 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function register(Container $app) |
||
| 19 | { |
||
| 20 | // using middleware function |
||
| 21 | $app['home_page'] = function($app) { |
||
| 22 | return middleware(function($req, $handler) use ($app) { |
||
| 23 | if (!in_array($req->getUri()->getPath(), [$app['basepath'].'/', $app['basepath']], true)) { |
||
| 24 | return $handler->handle($req); |
||
| 25 | } |
||
| 26 | |||
| 27 | $response = new Response(); |
||
| 28 | $response->getBody()->write("This is the home. Try '/hi' or anithing else"); |
||
| 29 | |||
| 30 | return $response; |
||
| 31 | }); |
||
| 32 | }; |
||
| 33 | |||
| 34 | // using path function |
||
| 35 | $app['hello_page'] = function($app) { |
||
| 36 | return path($app['basepath'].'/hi', middleware(function($req, $handler) { |
||
| 37 | $response = new Response(); |
||
| 38 | $response->getBody()->write("Hi. Try anything but/hi"); |
||
| 39 | |||
| 40 | return $response; |
||
| 41 | })); |
||
| 42 | }; |
||
| 43 | |||
| 44 | // using standard middleware as defaultt page |
||
| 45 | $app['default_page'] = function($app) { return new MyMiddleware($app);}; |
||
| 46 | |||
| 49 |