Announcing Adroit v0.4.0

Announcing Adroit v0.4.0

Over the course of the last few months we worked hard to improve our Adroit middleware. The result is the recently released version v0.4.0 which turned Adroit into a "real" ADR / PSR-7 middleware. We extracted the routing component into a separate package called Pathfinder and splitted "monolithic" middleware into smaller components. In addition to that we introduced the concept of several hooks to be able to add "custom logic" in between the execution of the different steps in the ADR workflow.


The following hooks can be used:

// Gets piped in front of the ActionResolverMiddleware
$adroit->beforeResolveAction($yourMiddleware);

// Gets piped in front of the ActionExecutorMiddleware
$adroit->beforeExecuteAction($yourMiddleware);

// Gets piped in front of the ResponderResolverMiddleware
$adroit->beforeResolveResponder($yourMiddleware);

// Gets piped in front of the ResponderExecutorMiddleware
$adroit->beforeExecuteResponder($yourMiddleware);


The hooks are basically separate middleware instances that follow the same method signature as the Adroit itself:

function (ServerRequestInterface $request, ResponseInterface $response, 
    callable $next = null) {
    // do what ever needs to be done

   if ($next)
       $response = $next($request, $response);
   }

   return $response;
}


You could for example implement a hook to check if the user is allowed to execute an action. The middleware could be added via the beforeResolveAction() method to make sure that only in case of an authenticated user the action gets created and executed.


Eintrag von Peter Hildenbrand am 12.07.2016

Tags: Adroit, ADR, PHP, PSR-7

Diese Webseite verwendet Cookies, um die Bedienfreundlichkeit zu erhöhen. Mit der Nutzung unserer Webseite wird das Einverständnis erklärt, dass wir Cookies verwenden. Weitere Informationen.