Merge pull request #10675 from nextcloud/enh/noid/middleware-flow

This commit is contained in:
Julius Härtl 2023-06-26 16:30:05 +02:00 committed by GitHub
commit c19a04f486
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -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:

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB