-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
2.0.0Action or feature to the 2.0.0 versionAction or feature to the 2.0.0 versionenhancementNew feature or requestNew feature or request
Description
In the next major version of Armor, a interesting feature could be implemented: the capability to create middlewares to the application.
The method that would be used to define these middlewares would be named Application#middleware(). It would work like this:
// ...
$app = ...;
$app->middleware(function(Request $req, Response $res) {
// ...
});
$app->middleware('auth', function(Request $req, Response $res) {
// ...
});That is, this method could receive:
- The callback function, that for every request would be one of the first functions that would manipulate the request and response objects, what create the need of adapting these objects to be "extensible" (receive external variables and/or functions);
-
$app->middleware(function(Request $req, Response $res) { $req->user = auth_user_from_req($req); $res->render = function() { // ... }; });
-
- And, optionally, a string that would identify this specific middleware, if these can be implemented "globally", or you want to just use a specific middleware, for example;
-
$app->middleware('auth', function(...) { ... }); $app->get('/dashboard', function(...) { ... })->preprocess('auth');
-
It's a feature to think about.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
2.0.0Action or feature to the 2.0.0 versionAction or feature to the 2.0.0 versionenhancementNew feature or requestNew feature or request