-
Notifications
You must be signed in to change notification settings - Fork 282
Request hook #5433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Request hook #5433
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <?php | ||
|
|
||
| namespace Icinga\Application\Hook; | ||
|
|
||
| use Icinga\Application\Hook; | ||
| use Icinga\Application\Logger; | ||
| use Icinga\Web\Request; | ||
| use Throwable; | ||
|
|
||
| abstract class RequestHook extends Hook | ||
| { | ||
| /** | ||
| * Triggered after a request has been dispatched | ||
| * | ||
| * @param Request $request | ||
| * | ||
| * @return void | ||
| */ | ||
| abstract public function onPostDispatch(Request $request): void; | ||
|
|
||
| /** | ||
| * Call the onPostDispatch() method of all registered RequestHooks | ||
| * | ||
| * @param Request $request | ||
| * | ||
| * @return void | ||
| */ | ||
| final public static function postDispatch(Request $request): void | ||
| { | ||
| foreach (static::all('Request') as $hook) { | ||
| try { | ||
| $hook->onPostDispatch($request); | ||
| } catch (Throwable $e) { | ||
| Logger::error('Failed to execute hook on request: %s', $e); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,29 +3,30 @@ | |
|
|
||
| namespace Icinga\Web\Controller; | ||
|
|
||
| use Icinga\Application\Modules\Module; | ||
| use Icinga\Common\PdfExport; | ||
| use Icinga\File\Pdf; | ||
| use Icinga\Util\Csp; | ||
| use Icinga\Web\View; | ||
| use ipl\I18n\Translation; | ||
| use Zend_Controller_Action; | ||
| use Zend_Controller_Action_HelperBroker; | ||
| use Zend_Controller_Request_Abstract; | ||
| use Zend_Controller_Response_Abstract; | ||
| use Icinga\Application\Benchmark; | ||
| use Icinga\Application\Config; | ||
| use Icinga\Application\Hook\RequestHook; | ||
| use Icinga\Application\Modules\Module; | ||
| use Icinga\Authentication\Auth; | ||
| use Icinga\Common\PdfExport; | ||
| use Icinga\Exception\Http\HttpMethodNotAllowedException; | ||
| use Icinga\Exception\IcingaException; | ||
| use Icinga\Exception\ProgrammingError; | ||
| use Icinga\File\Pdf; | ||
| use Icinga\Forms\AutoRefreshForm; | ||
| use Icinga\Security\SecurityException; | ||
| use Icinga\Util\Csp; | ||
| use Icinga\Web\Session; | ||
| use Icinga\Web\Url; | ||
| use Icinga\Web\UrlParams; | ||
| use Icinga\Web\View; | ||
| use Icinga\Web\Widget\Tabs; | ||
| use Icinga\Web\Window; | ||
| use ipl\I18n\Translation; | ||
| use Zend_Controller_Action; | ||
| use Zend_Controller_Action_HelperBroker; | ||
| use Zend_Controller_Request_Abstract; | ||
| use Zend_Controller_Response_Abstract; | ||
|
|
||
| /** | ||
| * Base class for all core action controllers | ||
|
|
@@ -520,6 +521,8 @@ public function postDispatch() | |
|
|
||
| if ($this->isXhr()) { | ||
| $this->postDispatchXhr(); | ||
| } else { | ||
| RequestHook::postDispatch($req); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think letting the hook decide would be clever AND smart. I mean, anyone could provide a hook... and wonder why some requests are missing. If
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I already discussed this w/ @jrauh01. We will call
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jrauh01 Please also add the following to our public function isAutoRefresh(): bool
{
return $this->getHeader('X-Icinga-Autorefresh');
} |
||
| } | ||
|
|
||
| $this->shutdownSession(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.