no-framework-tutorial/implementation/10/config/routes.php

13 lines
452 B
PHP
Raw Normal View History

2022-05-23 20:08:50 +00:00
<?php declare(strict_types=1);
use FastRoute\RouteCollector;
use Lubian\NoFramework\Action\Hello;
use Lubian\NoFramework\Action\Other;
2022-05-30 12:27:48 +00:00
use Psr\Http\Message\ResponseInterface;
2022-05-23 20:08:50 +00:00
return function (RouteCollector $r) {
$r->addRoute('GET', '/hello[/{name}]', Hello::class);
$r->addRoute('GET', '/other', [Other::class, 'handle']);
2022-05-30 12:27:48 +00:00
$r->addRoute('GET', '/', fn (ResponseInterface $r) => $r->withHeader('Location', '/hello') ->withStatus(302));
2022-05-23 20:08:50 +00:00
};