Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e987f84

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

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

Lines changed: 19 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,27 @@
121124
</tr>
122125
</tbody>
123126
</table>
127+
{{ dump(trace) }}
124128
{% endfor %}
125129
{% endif %}
126130
</div>
127131
</div>
128132
{% endfor %}
129133
{% endif %}
130134
</div>
135+
136+
<script type="text/javascript">//<![CDATA[
137+
138+
document.querySelectorAll('[data-clipboard-text]').forEach(function(button) {
139+
button.addEventListener('click', function() {
140+
navigator.clipboard.writeText(button.getAttribute('data-clipboard-text'));
141+
})
142+
});
143+
144+
//]]></script>
145+
131146
{% endblock %}
147+
148+
{% macro render_curl(trace) %}
149+
curl {{ trace.url }}
150+
{% endmacro %}

0 commit comments

Comments
 (0)