this code 100% failes to stop route execurtion.
$app = new Micro($di);
$app->before(function () use ($app) {
// Auth logic here.
return $isAuthed; // this is false when testing.
});
$app->after(function() use ($app){
// this code still executes. even though wer ereturned false in the before fucntion
if (!$app->response->isSent()){
$app->response->send();
}
});
// the base response for the api
$app->get('/',function() use ($app){
$app->response->setJsonContent('Welcome to the Api');
});
// not found response.
$app->notFound(function () use ($app) {
$app->response->setHeader("Content-Type", "application/json");
$app->response->setStatusCode(404,'Not Found');
$app->response->setJsonContent('Not Found');
return $app->response;
});
// routes
require ( APP_PATH. '/config/v2routes.php' );
foreach($v2 as $route){
$app->mount($route);
}