php - Slim Set Middleware -


what's right way set custom middleware specific route calling setmiddleware method? wrote custom middleware:

custommiddleware

namespace slim\middleware;  class custommiddleware extends \slim\middleware {     public function __construct() {         // omitted     }      public function call() {         // omitted     } } 

then want set specific route:

$app->get(         '/api/users(/)', function () use ($app) {     echo 'middleware passed.'; })->setmiddleware(new \slim\middleware\custommiddleware()); 

using way get:

invalidargumentexception: route middleware must callable or array of callables in c:\dev\rest\slim\route.php on line 336 

any help? many thanks.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -