mirror of
https://github.com/nextcloud/documentation.git
synced 2026-03-26 13:28:45 +07:00
feat: visualization of middleware flow
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
@@ -11,6 +11,9 @@ Middleware is logic that is run before and after each request and is modelled af
|
||||
* ``afterController``: This is being run after a successful controller method call and allows the manipulation of a Response object. The middleware is run in reverse order
|
||||
* ``beforeOutput``: This is being run after the response object has been rendered and allows the manipulation of the outputted text. The middleware is run in reverse order
|
||||
|
||||
.. figure:: ../images/middleware-flow-horiz.png
|
||||
:alt: Middleware flow chart
|
||||
|
||||
To generate your own middleware, simply inherit from the Middleware class and overwrite the methods that should be used.
|
||||
|
||||
|
||||
@@ -128,7 +131,7 @@ Middlewares can also be added using the **registerMiddleware** method of the con
|
||||
|
||||
public function __construct(array $urlParams = []) {
|
||||
parent::__construct('myapp', $urlParams);
|
||||
|
||||
|
||||
$container = $this->getContainer();
|
||||
|
||||
// executed in the order that it is registered
|
||||
@@ -142,7 +145,7 @@ Middlewares can also be added using the **registerMiddleware** method of the con
|
||||
The order is important! The middleware that is registered first gets run first in the **beforeController** method. For all other hooks, the order is being reversed, meaning: if a middleware is registered first, it gets run last.
|
||||
|
||||
|
||||
Parsing annotations
|
||||
Parsing annotations
|
||||
-------------------
|
||||
|
||||
Sometimes it is useful to conditionally execute code before or after a controller method. This can be done by defining custom annotations. An example would be to add a custom authentication method or simply add an additional header to the response. To access the parsed annotations, inject the **ControllerMethodReflector** class:
|
||||
|
||||
BIN
developer_manual/images/middleware-flow-horiz.png
Normal file
BIN
developer_manual/images/middleware-flow-horiz.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
Reference in New Issue
Block a user