Skip to content

Commit ca02c62

Browse files
author
Denis Brumann
committed
Adds link to debug token.
1 parent 1f28ecc commit ca02c62

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
77
### Added
88

99
- Configured clients are now tagged with `'httplug.client'`
10+
- Adds a link to profiler page when response is from a Symfony application with
11+
profiler enabled
1012

1113
## 1.16.0 - 2019-06-05
1214

src/Collector/ProfileClient.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ private function collectResponseInformations(ResponseInterface $response, Stopwa
173173
$stack->setDuration($event->getDuration());
174174
$stack->setResponseCode($response->getStatusCode());
175175
$stack->setClientResponse($this->formatter->formatResponse($response));
176+
if ($response->hasHeader('X-Debug-Token-Link')) {
177+
$stack->setDebugToken($response->getHeaderLine('X-Debug-Token'));
178+
$stack->setDebugTokenLink($response->getHeaderLine('X-Debug-Token-Link'));
179+
}
176180
}
177181

178182
/**

src/Collector/Stack.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ final class Stack
8181
*/
8282
private $responseCode;
8383

84+
/**
85+
* @var string|null
86+
*/
87+
private $debugToken;
88+
89+
/**
90+
* @var string|null
91+
*/
92+
private $debugTokenLink;
93+
8494
/**
8595
* @var int
8696
*/
@@ -277,6 +287,38 @@ public function setResponseCode($responseCode)
277287
$this->responseCode = $responseCode;
278288
}
279289

290+
/**
291+
* @return string
292+
*/
293+
public function getDebugToken()
294+
{
295+
return $this->debugToken;
296+
}
297+
298+
/**
299+
* @param string $debugToken
300+
*/
301+
public function setDebugToken($debugToken)
302+
{
303+
$this->debugToken = $debugToken;
304+
}
305+
306+
/**
307+
* @return string
308+
*/
309+
public function getDebugTokenLink()
310+
{
311+
return $this->debugTokenLink;
312+
}
313+
314+
/**
315+
* @param string $debugTokenLink
316+
*/
317+
public function setDebugTokenLink($debugTokenLink)
318+
{
319+
$this->debugTokenLink = $debugTokenLink;
320+
}
321+
280322
/**
281323
* @return string
282324
*/

src/Resources/views/stack.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
{{ stack.clientRequest|httplug_markup|nl2br }}
3939
</div>
4040
<div class="httplug-message card">
41-
<h4>Response</h4>
41+
<h4>Response {% if stack.debugTokenLink %}<span class="label status-info"><a href="{{ stack.debugTokenLink }}">Debug Token: {{ stack.debugToken }}</a></span>{% endif %}</h4>
4242
{{ stack.clientResponse|httplug_markup|nl2br }}
4343
</div>
4444
</div>

0 commit comments

Comments
 (0)