Skip to content

Commit 01329da

Browse files
Change execution order of request and response handlers (first the API Class' handler and then whichever defined through constructor parameter
1 parent b4038f4 commit 01329da

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/support/forge/api/Traits/Client/Stackables.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,24 @@ protected function getStacks($config)
1919

2020
$stack = $config['client']['handler'] ?? HandlerStack::create();
2121

22+
if (method_exists($this, 'requestHandler')) {
23+
$function = [$this, 'requestHandler'];
24+
$stack->push($this->getRequestStack($function));
25+
}
2226
if (!empty($config['settings']['requestHandler'])) {
2327
$request = $this->getRequestStack($config['settings']['requestHandler']);
2428
$stack->push($request);
2529
}
26-
if (method_exists($this, 'requestHandler')) {
27-
$function = [$this, 'requestHandler'];
28-
$stack->push($this->getRequestStack($function));
30+
31+
if (method_exists($this, 'responseHandler')) {
32+
$function = [$this, 'responseHandler'];
33+
$stack->push($this->getResponseStack($function));
2934
}
3035

3136
if (!empty($config['settings']['responseHandler'])) {
3237
$response = $this->getResponseStack($config['settings']['responseHandler']);
3338
$stack->push($response);
3439
}
35-
if (method_exists($this, 'responseHandler')) {
36-
$function = [$this, 'responseHandler'];
37-
$stack->push($this->getResponseStack($function));
38-
}
3940

4041
if ($config['log'] ?? true !== false) {
4142
$logger = $this->getLoggerStack($config['log'] ?? null);

0 commit comments

Comments
 (0)