-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcurl.html
More file actions
24 lines (24 loc) · 1.63 KB
/
Copy pathcurl.html
File metadata and controls
24 lines (24 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<div class="curl">
{% assign _headers = "" %}
{% assign _body = "" %}
{% assign _tmp = include.req | strip | newline_to_br | split: '<br />' %}
{% for l in _tmp %}
{% if forloop.first or forloop.last %}
{% elsif forloop.index0 == 1 %}
{% assign _url = l %}
{% elsif _body == empty %}
{% if l == blank %}
{% assign _body = l %}
{% else %}
{% capture _headers %}{{ _headers }}{{ l }}{% endcapture %}
{% endif %}
{% else %}
{% capture _body %}{{ _body }}{{ l }}{% endcapture %}
{% endif %}
{% endfor %}
{% assign _method = _url | split: ' ' | first %}
{% assign _url = _url | remove_first: _method | strip %}
{% highlight json %}{{ _method }} {{ _url }}{{ _headers }}{% if _body != blank %}
{{ _body | strip }}{% endif %}{% endhighlight %}
<button class="btn" data-clipboard-text="curl{% if _headers == blank %}{% if _body != blank %} -H 'Content-Type: application/json'{% endif %}{% else %}{% assign _tmp = _headers | strip | newline_to_br | strip_newlines | split: '<br />' %}{% for h in _tmp %} -H '{% assign _header_inspect = h | inspect %}{% assign _size = _header_inspect.size | minus: 12 %}{{ _header_inspect | slice: 6, _size | replace: '\"': '"' | replace: ''', '\'' }}'{% endfor %}{% endif %}{% if _body != blank %}{% assign _body_inspect = _body | strip | inspect %}{% assign _size = _body_inspect.size | minus: 12 %} --data-binary '{{ _body_inspect | slice: 6, _size | replace: '\"': '"' | replace: ''', '\'' | replace: '\n', ' '' }}'{% endif %} -X {{ _method }} 'localhost:8880{{ _url }}'"><i class="fa fa-clipboard"></i></button>
</div>