diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-08-25 21:16:20 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2018-08-25 21:48:39 +0200 |
commit | a1bc763a16ee8be109de5c9053fbc5eded53824e (patch) | |
tree | 7253db0c8ea918e82253bef3926bcba461a7105d /config | |
parent | 73c9d923e7cc77847cfcbff4b90ad4815699a4fa (diff) |
Added nikic/fast-route as routing dispatcher
Diffstat (limited to 'config')
-rw-r--r-- | config/app.php | 6 | ||||
-rw-r--r-- | config/routes.php | 14 |
2 files changed, 18 insertions, 2 deletions
diff --git a/config/app.php b/config/app.php index 6278f193..9af35eb4 100644 --- a/config/app.php +++ b/config/app.php @@ -15,13 +15,15 @@ return [ \Engelsystem\Http\SessionServiceProvider::class, \Engelsystem\Http\ResponseServiceProvider::class, \Engelsystem\Http\Psr7ServiceProvider::class, + \Engelsystem\Middleware\RouteDispatcherServiceProvider::class, + \Engelsystem\Middleware\RequestHandlerServiceProvider::class, ], // Application middleware 'middleware' => [ \Engelsystem\Middleware\SendResponseHandler::class, \Engelsystem\Middleware\ExceptionHandler::class, - \Engelsystem\Middleware\LegacyMiddleware::class, - \Engelsystem\Middleware\NotFoundResponse::class, + \Engelsystem\Middleware\RouteDispatcher::class, + \Engelsystem\Middleware\RequestHandler::class, ], ]; diff --git a/config/routes.php b/config/routes.php new file mode 100644 index 00000000..5296dbc7 --- /dev/null +++ b/config/routes.php @@ -0,0 +1,14 @@ +<?php + +use FastRoute\RouteCollector; +use Psr\Http\Message\ServerRequestInterface; + +/** @var RouteCollector $route */ + +/** Demo route endpoint, TODO: Remove */ +$route->addRoute('GET', '/hello/{name}', function ($request) { + /** @var ServerRequestInterface $request */ + $name = $request->getAttribute('name'); + + return response(sprintf('Hello %s!', htmlspecialchars($name))); +}); |