8000 [Profiler] Add HttpClient copy as curl feature · symfony/symfony@a00ba1b · GitHub
[go: up one dir, main page]

Skip to content

Commit a00ba1b

Browse files
[Profiler] Add HttpClient copy as curl feature
1 parent 0ab5eed commit a00ba1b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/http_client.html.twig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
22

3+
{% import _self as helper %}
4+
35
{% block toolbar %}
46
{% if collector.requestCount %}
57
{% set icon %}
@@ -88,6 +90,7 @@
8890
{% if trace.options is not empty %}
8991
{{ profiler_dump(trace.options, maxDepth=1) }}
9092
{% endif %}
93+
<button class="btn btn-sm" data-clipboard-text="{{ helper.render_curl(trace) }}">Copy-as-Curl</button>
9194
</th>
9295
{% if profiler_token and profiler_link %}
9396
<th>
@@ -121,11 +124,28 @@
121124
</tr>
122125
</tbody>
123126
</table>
127+
{# tmp: introspect the "trace" #}
128+
{{ dump(trace) }}
124129
{% endfor %}
125130
{% endif %}
126131
</div>
127132
</div>
128133
{% endfor %}
129134
{% endif %}
130135
</div>
136+
137+
<script type="text/javascript">//<![CDATA[
138+
139+
document.querySelectorAll('[data-clipboard-text]').forEach(function(button) {
140+
button.addEventListener('click', function() {
141+
navigator.clipboard.writeText(button.getAttribute('data-clipboard-text'));
142+
})
143+
});
144+
145+
//]]></script>
146+
131147
{% endblock %}
148+
149+
{% macro render_curl(trace) %}
150+
curl "{{ trace.url }}" --compressed -H "Connection: keep-alive" -v
151+
{% endmacro %}

0 commit comments

Comments
 (0)
0