티스토리 뷰
Middleware
Application middleware
<?php $timer = function($request, $response, $next){ // before $start = microtime(true); // call next middleware $response = $next($request, $response); // after $taken = microtime(true) - $start; $response->write("<!-- Time taken: $taken -->"); return $response; } $app->add($timer);
Route middleware
<?php $app->get('/hello/{name}', function(...){...}) ->add(function($request, $response, $next){ // before : sanitise route parameter $name = strip_tags($request->getAttribute('name')); $request = $request->withAttribute('name', $name); return $next($request, $response); });
Leverage middleware
Application level:
Authentication
Navigation
Session
Route level:
Access control
Validation
'■ 백엔드 ■ > Slim' 카테고리의 다른 글
Slim Framework 3 Skeleton Application (0) | 2018.06.25 |
---|---|
Twig views (0) | 2018.05.24 |
Routes (0) | 2018.05.24 |
index.php (0) | 2018.05.24 |
03. 웹서버 설정 (0) | 2018.05.23 |
댓글