-
Notifications
You must be signed in to change notification settings - Fork 56
/
web_basket.html.go
848 lines (773 loc) · 29.8 KB
/
web_basket.html.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
package main
const (
basketPageContentTemplate = `<!DOCTYPE html>
<html>
<head lang="en">
<title>Request Basket: {{.Basket}}</title>{{.ThemeCSS}}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css">
<script src="https://code.jquery.com/jquery-3.6.4.min.js" integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<style>
body { padding-top: 70px; }
h1 { margin-top: 2px; }
#more { margin-left: 100px; }
.copy-req-btn:hover,
.copy-url-btn:hover { cursor: pointer; }
</style>
<script>
(function($) {
var basketUrl = window.location.protocol + "//" + window.location.host + "{{.Prefix}}/{{.Basket}}";
var fetchedCount = 0;
var fetchedRequests = {};
var totalCount = 0;
var currentConfig;
var autoRefresh = false;
var autoRefreshId;
function getParam(name) {
var params = new RegExp("[\\?&]" + name + "=([^&#]*)").exec(window.location.search);
return (params && params.length) ? params[1] : null;
}
function getBasketToken() {
return localStorage.getItem("basket_{{.Basket}}");
}
function getToken() {
var token = getBasketToken();
if (!token) { // fall back to master token if provided
token = sessionStorage.getItem("master_token");
}
return token;
}
function onAjaxError(jqXHR) {
if (jqXHR.status == 401) {
localStorage.removeItem("basket_{{.Basket}}");
enableAutoRefresh(false);
$("#token_dialog").modal({ keyboard : false });
} else {
$("#error_message_label").html("HTTP " + jqXHR.status + " - " + jqXHR.statusText);
$("#error_message_text").html(jqXHR.responseText);
$("#error_message").modal();
}
}
function escapeHTML(value) {
return value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");
}
function renderRequest(id, request) {
var path = request.path;
if (request.query) {
path += "?";
if (request.query.length > 70) {
path += request.query.substring(0, 67) + "...";
} else {
path += request.query;
}
}
var headers = [];
for (header in request.headers) {
headers.push(header + ": " + request.headers[header].join(","));
}
var headerClass = "default";
switch(request.method) {
case "GET":
headerClass = "success";
break;
case "PUT":
headerClass = "info";
break;
case "POST":
headerClass = "primary";
break;
case "DELETE":
headerClass = "danger";
break;
}
var date = new Date(request.date);
var html = '<div class="row"><div class="col-md-2"><h4 class="text-' + headerClass + '">[' + request.method + ']</h4>' +
'<div><i class="glyphicon glyphicon-time" title="' + date.toString() + '"></i> ' + date.toLocaleTimeString() +
'</div><div><i class="glyphicon glyphicon-calendar" title="' + date.toString() + '"></i> ' + date.toLocaleDateString() +
'</div></div><div class="col-md-10"><div class="panel-group" id="' + id + '">' +
'<div class="panel panel-' + headerClass + '"><div class="panel-heading"><h4 class="panel-title">' + escapeHTML(path) +
'<span id="' + id + '_copy_request_btn" for="' + requestId + '" class="pull-right copy-req-btn">' +
'<span title="Copy Request Details" class="glyphicon glyphicon-copy"></span></span></h4></div></div>' +
'<div class="panel panel-default"><div class="panel-heading"><h4 class="panel-title">' +
'<a class="collapsed" data-toggle="collapse" data-parent="#' + id + '" href="#' + id + '_headers">Headers</a></h4></div>' +
'<div id="' + id + '_headers" class="panel-collapse collapse">' +
'<div class="panel-body"><pre>' + escapeHTML(headers.join('\n')) + '</pre></div></div></div>';
if (request.query) {
html += '<div class="panel panel-default"><div class="panel-heading"><h4 class="panel-title">' +
'<a class="collapsed" data-toggle="collapse" data-parent="#' + id + '" href="#' + id + '_query">Query Params</a></h4></div>' +
'<div id="' + id + '_query" class="panel-collapse collapse">' +
'<div class="panel-body"><pre>' + escapeHTML(request.query.split('&').join('\n')) + '</pre></div></div></div>';
}
if (request.body) {
html += '<div class="panel panel-default"><div class="panel-heading"><h4 class="panel-title">' +
'<a class="collapsed" data-toggle="collapse" data-parent="#' + id + '" href="#' + id + '_body">Body</a></h4></div>' +
'<div id="' + id + '_body" class="panel-collapse collapse in">' +
'<div class="panel-body"><pre>' + escapeHTML(request.body) + '</pre></div></div></div>';
}
html += '</div></div></div><hr/>';
return html;
}
function addRequests(data) {
totalCount = data.total_count;
$("#requests_count").html(data.count + " (" + totalCount + ")");
if (data.count > 0) {
$("#empty_basket").addClass("hide");
$("#requests_link").removeClass("hide");
} else {
$("#empty_basket").removeClass("hide");
$("#requests_link").addClass("hide");
}
if (data && data.requests) {
var requests = $("#requests");
var index, request;
for (index = 0; index < data.requests.length; ++index) {
request = data.requests[index];
requestId = "req" + fetchedCount;
requests.append(renderRequest(requestId, request));
fetchedRequests[requestId] = JSON.stringify(request, null, 2);
if (request.body) {
var format = getContentFormat(request.headers["Content-Type"]);
if (format !== "UNKNOWN") {
var button = $('<button id="' + requestId + '_body_format_btn" for="' + requestId +
'" format="' + format + '" type="button" class="btn btn-default">Format Content</button>');
$("#" + requestId + "_body div pre").after(button);
button.on("click", function(event) {
formatBody(this);
});
}
}
$("#" + requestId + "_copy_request_btn").on("click", function(event) {
copyRequest(this);
});
fetchedCount++;
}
}
if (data.has_more) {
$("#more").removeClass("hide");
$("#more_count").html(data.count - fetchedCount);
} else {
$("#more").addClass("hide");
$("#more_count").html("");
}
}
function getContentFormat(contentType) {
// array of header values to string
contentType = (contentType || []).join(",");
if (/^application\/x-www-form-urlencoded.*/i.test(contentType)) {
return "FORM";
} else if (/^(application|text)\/(json|.+\+json).*/i.test(contentType)) {
return "JSON";
} else if (/^(application|text)\/(xml|.+\+xml).*/i.test(contentType)) {
return "XML";
} else {
return "UNKNOWN";
}
}
function formatBody(btn) {
var button = $(btn);
var requestId = button.attr("for");
var format = button.attr("format");
var body = $("#" + requestId + "_body div pre");
var code = $('<code class="' + getHighlightLang(format) + '"></code>');
code.text(formatText(body.text(), format));
body.empty();
body.append(code);
// highlight
hljs.highlightBlock(code.get(0));
// avoid further formatting
button.remove();
}
function getHighlightLang(format) {
switch(format) {
case "JSON":
case "XML":
return "language-" + format.toLowerCase();
default:
return "no-highlight";
}
}
function formatText(text, format) {
switch (format) {
case "JSON":
return JSON.stringify(JSON.parse(text), null, 2);
case "XML":
return formatXml(text, " ");
case "FORM":
return text.split("&").map(decodeURIComponent).join("\n");
}
}
function formatXml(xml, tab) {
var formatted = "";
// minify first
xml = xml.replace(/(>)\s*(<)/g, "$1$2");
xml = xml.replace(/(>)(<)(\/*)/g, "$1\r\n$2$3");
var pad = 0;
$.each(xml.split("\r\n"), function(index, node) {
var indent = 0;
if (node.match(/.+<\/\w[^>]*>$/)) {
indent = 0;
} else if (node.match(/^<\/\w/)) {
if (pad != 0) {
pad -= 1;
}
} else if (node.match(/^<\w[^>]*[^\/]>.*$/)) {
indent = 1;
} else {
indent = 0;
}
var padding = "";
for (var i = 0; i < pad; i++) {
padding += tab;
}
formatted += padding + node + "\r\n";
pad += indent;
});
return formatted;
}
function resetCopyButtonsState() {
$(".copy-req-btn").html('<span title="Copy Request Details" class="glyphicon glyphicon-copy"></span>');
$(".copy-url-btn").html('<span title="Copy URL" class="glyphicon glyphicon-copy"></span>');
}
function copyRequest(btn) {
var button = $(btn);
var requestId = button.attr("for");
if (copyToClipboard(fetchedRequests[requestId], button.get(0))) {
resetCopyButtonsState();
// mark as copied
button.html('<span title="This request is copied to your clipboard." class="glyphicon glyphicon-check"></span>');
}
}
function copyBasketUrl(btn) {
var button = $(btn);
if (copyToClipboard(basketUrl, button.get(0))) {
resetCopyButtonsState();
// mark as copied
button.html('<span title="Basket URL is copied to your clipboard." class="glyphicon glyphicon-check"></span>');
}
}
function fetchRequests() {
$.ajax({
method: "GET",
url: "{{.Prefix}}/api/baskets/{{.Basket}}/requests?skip=" + fetchedCount,
headers: {
"Authorization" : getToken()
}
}).done(addRequests).fail(onAjaxError);
}
function fetchTotalCount() {
$.ajax({
method: "GET",
url: "{{.Prefix}}/api/baskets/{{.Basket}}/requests?max=0",
headers: {
"Authorization" : getToken()
}
}).done(function(data) {
if (data && (data.total_count != totalCount)) {
refresh();
}
}).fail(onAjaxError);
}
function fetchResponse(method) {
// keep in sync during page refresh
$("#response_method").val(method);
$.ajax({
method: "GET",
url: "{{.Prefix}}/api/baskets/{{.Basket}}/responses/" + method,
headers: {
"Authorization" : getToken()
}
}).done(function(data) {
displayResponse(data);
}).fail(onAjaxError);
}
function displayResponse(response) {
$("#response_status").val(response.status);
$("#response_body").val(response.body);
$("#response_is_template").prop("checked", response.is_template);
// headers
$("#response_headers").html(""); // reset
var row;
var index = 0;
for (header in response.headers) {
row = $('<div class="row"></div>');
row.append('<div class="col-md-3"><input type="input" class="form-control" id="header_name_' + index +
'" value="' + escapeHTML(header) + '" placeholder="name"></div>');
// multi-value headers are not supported, simply join values through comma
row.append('<div class="col-md-7"><input type="input" class="form-control" id="header_value_' + index +
'" value="' + escapeHTML(response.headers[header].join(',')) + '" placeholder="value"></div>');
row.appendTo($("#response_headers"));
index++;
}
// button or new header
if (index > 0) {
addHeaderButton(row);
} else {
addHeader();
}
}
function addHeader() {
$("#headers_add").remove();
var index = $("#response_headers > div.row").length;
var row = $('<div class="row"><div class="col-md-3"><input type="input" class="form-control" id="header_name_' + index +
'" placeholder="name"></div><div class="col-md-7"><input type="input" class="form-control" id="header_value_' + index +
'" placeholder="value"></div></div>');
row.appendTo($("#response_headers"));
addHeaderButton(row);
}
function addHeaderButton(row) {
row.append('<div id="headers_add" class="col-md-1"><button id="headers_add_btn" type="button" title="Add Header" class="btn btn-success">' +
'<span class="glyphicon glyphicon-plus-sign"></span></button></div>');
$("#headers_add_btn").on("click", function(event) {
addHeader();
});
}
function updateResponse() {
var method = $("#response_method").val();
var response = {};
response.status = parseInt($("#response_status").val());
response.body = $("#response_body").val();
response.is_template = $("#response_is_template").prop("checked");
response.headers = {};
$("#response_headers > div.row").each( function(index) {
var name = $("#header_name_" + index).val();
var value = $("#header_value_" + index).val();
if (name && name.length > 0 && value && value.length > 0) {
response.headers[name] = [ value ];
}
});
$.ajax({
method: "PUT",
url: "{{.Prefix}}/api/baskets/{{.Basket}}/responses/" + method,
dataType: "json",
data: JSON.stringify(response),
headers: {
"Authorization" : getToken()
}
}).done(function(data) {
alert("Response for HTTP " + method + " is updated");
}).fail(onAjaxError);
}
function updateConfig() {
if (currentConfig && (
currentConfig.forward_url != $("#basket_forward_url").val() ||
currentConfig.proxy_response != $("#basket_proxy_response").prop("checked") ||
currentConfig.expand_path != $("#basket_expand_path").prop("checked") ||
currentConfig.insecure_tls != $("#basket_insecure_tls").prop("checked") ||
currentConfig.capacity != $("#basket_capacity").val()
)) {
currentConfig.forward_url = $("#basket_forward_url").val();
currentConfig.proxy_response = $("#basket_proxy_response").prop("checked");
currentConfig.expand_path = $("#basket_expand_path").prop("checked");
currentConfig.insecure_tls = $("#basket_insecure_tls").prop("checked");
currentConfig.capacity = parseInt($("#basket_capacity").val());
$.ajax({
method: "PUT",
url: "{{.Prefix}}/api/baskets/{{.Basket}}",
dataType: "json",
data: JSON.stringify(currentConfig),
headers: {
"Authorization" : getToken()
}
}).done(function(data) {
alert("Basket is reconfigured");
}).fail(onAjaxError);
}
}
function refresh() {
$("#requests").html(""); // reset
fetchedCount = 0;
fetchedRequests = {};
fetchRequests(); // fetch latest
}
function enableAutoRefresh(enable) {
if (autoRefresh != enable) {
var btn = $("#auto_refresh");
if (enable) {
autoRefreshId = setInterval(fetchTotalCount, 3000);
btn.removeClass("btn-default");
btn.addClass("btn-success");
btn.attr("title", "Auto-Refresh is Enabled");
} else {
clearInterval(autoRefreshId);
btn.removeClass("btn-success");
btn.addClass("btn-default");
btn.attr("title", "Auto-Refresh is Disabled");
}
autoRefresh = enable;
}
}
function config() {
$.ajax({
method: "GET",
url: "{{.Prefix}}/api/baskets/{{.Basket}}",
headers: {
"Authorization" : getToken()
}
}).done(function(data) {
if (data) {
currentConfig = data;
$("#basket_forward_url").val(currentConfig.forward_url);
$("#basket_proxy_response").prop("checked", currentConfig.proxy_response);
$("#basket_expand_path").prop("checked", currentConfig.expand_path);
$("#basket_insecure_tls").prop("checked", currentConfig.insecure_tls);
$("#basket_capacity").val(currentConfig.capacity);
$("#config_dialog").modal();
}
}).fail(onAjaxError);
}
function responses() {
$("#responses_dialog").modal();
}
function deleteRequests() {
$.ajax({
method: "DELETE",
url: "{{.Prefix}}/api/baskets/{{.Basket}}/requests",
headers: {
"Authorization" : getToken()
}
}).done(function(data) {
refresh();
}).fail(onAjaxError);
}
function destroyBasket() {
$("#destroy_dialog").modal("hide");
enableAutoRefresh(false);
$.ajax({
method: "DELETE",
url: "{{.Prefix}}/api/baskets/{{.Basket}}",
headers: {
"Authorization" : getToken()
}
}).done(function(data) {
localStorage.removeItem("basket_{{.Basket}}");
window.location.href = "{{.Prefix}}/web";
}).fail(onAjaxError);
}
function copyToClipboard(text, element) {
var position = element || document.body.firstChild;
var textArea = document.createElement("textarea");
textArea.value = text;
position.parentNode.insertBefore(textArea, position);
textArea.focus();
textArea.select();
var copied;
try {
copied = document.execCommand("copy");
} catch (err) {
copied = false;
}
position.parentNode.removeChild(textArea);
return copied;
}
function shareBasket() {
var token = getBasketToken();
if (token && copyToClipboard(window.location + "?token=" + token)) {
resetCopyButtonsState();
alert("A link to share this basket was copied to your clipboard.");
}
}
function acceptSharedBasket() {
var token = getParam("token");
if (token) {
var currentToken = getBasketToken();
if (!currentToken) {
// remember basket token
localStorage.setItem("basket_{{.Basket}}", token);
} else if (currentToken !== token) {
if (confirm("The access token for the '{{.Basket}}' basket \n" +
"from query parameter is different to the token that is \n" +
"already stored in your browser.\n\n" +
"If you trust this link choose 'OK' and existing token will be \n" +
"replaced with the new one, otherwise choose 'Cancel'.\n\n" +
"Do you want to replace the access token of this basket?")) {
localStorage.setItem("basket_{{.Basket}}", token);
}
}
// remove token from location URL
window.location.href = "{{.Prefix}}/web/{{.Basket}}";
}
}
// Initialization
$(document).ready(function() {
$(".basket_uri").html(basketUrl);
// dialogs
$("#token_dialog").on("hidden.bs.modal", function (event) {
localStorage.setItem("basket_{{.Basket}}", $("#basket_token").val());
fetchRequests();
});
$("#config_form").on("submit", function(event) {
$("#config_dialog").modal("hide");
updateConfig();
event.preventDefault();
});
// buttons
$("#refresh").on("click", function(event) {
refresh();
});
$("#auto_refresh").on("click", function(event) {
enableAutoRefresh(!autoRefresh);
});
$("#config").on("click", function(event) {
config();
});
$("#responses").on("click", function(event) {
responses();
});
$("#share").on("click", function(event) {
shareBasket();
});
$("#delete").on("click", function(event) {
deleteRequests();
});
$("#destroy").on("click", function(event) {
$("#destroy_dialog").modal();
});
$("#destroy_confirmed").on("click", function(event) {
destroyBasket();
});
$("#fetch_more").on("click", function(event) {
fetchRequests();
});
$("#response_method").on("change", function(event) {
fetchResponse($(this).val());
});
$("#update_response").on("click", function(event) {
updateResponse();
});
// copy basket URL
$(".copy-url-btn").on("click", function(event) {
copyBasketUrl(this);
});
// shared basket link
acceptSharedBasket();
// hide share basket button
if (!getBasketToken()) {
$("#share").hide();
}
// autorefresh and initial fetch
if (getToken()) {
enableAutoRefresh(true);
}
fetchRequests();
fetchResponse("GET");
});
})(jQuery);
</script>
</head>
<body>
<!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="{{.Prefix}}/web">Request Baskets</a>
</div>
<div class="collapse navbar-collapse">
<form class="navbar-form navbar-right">
<button id="refresh" type="button" title="Refresh" class="btn btn-default">
<span class="glyphicon glyphicon-refresh"></span>
</button>
<button id="auto_refresh" type="button" title="Auto Refresh" class="btn btn-default">
<span class="glyphicon glyphicon-repeat"></span>
</button>
<button id="config" type="button" title="Settings" class="btn btn-default">
<span class="glyphicon glyphicon-cog"></span>
</button>
<button id="responses" type="button" title="Responses" class="btn btn-default">
<!-- glyphicon-tags | glyphicon-transfer -->
<span class="glyphicon glyphicon-transfer"></span>
</button>
<button id="share" type="button" title="Share Basket" class="btn btn-default">
<span class="glyphicon glyphicon-link"></span>
</button>
<button id="delete" type="button" title="Delete Requests" class="btn btn-warning">
<span class="glyphicon glyphicon-fire"></span>
</button>
<button id="destroy" type="button" title="Destroy Basket" class="btn btn-danger">
<span class="glyphicon glyphicon-trash"></span>
</button>
</form>
</div>
</div>
</nav>
<!-- Login dialog -->
<form>
<div class="modal fade" id="token_dialog" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content panel-warning">
<div class="modal-header panel-heading">
<h4 class="modal-title">Token required</h4>
</div>
<div class="modal-body">
<p>You are not authorized to access this basket. Please enter this basket token or choose another basket.</p>
<div class="form-group">
<label for="basket_token" class="control-label">Token:</label>
<input type="password" class="form-control" id="basket_token">
</div>
</div>
<div class="modal-footer">
<a href="{{.Prefix}}/web" class="btn btn-default">Back to list of Baskets</a>
<button type="submit" class="btn btn-success" data-dismiss="modal">Authorize</button>
</div>
</div>
</div>
</div>
</form>
<!-- Config dialog -->
<form id="config_form">
<div class="modal fade" id="config_dialog" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content panel-default">
<div class="modal-header panel-heading">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title" id="config_dialog_label">Configuration Settings</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label for="basket_forward_url" class="control-label">Forward URL:</label>
<input type="input" class="form-control" id="basket_forward_url">
</div>
<div class="checkbox">
<label><input type="checkbox" id="basket_insecure_tls">
<abbr class="text-danger" title="Warning! Enabling this feature will bypass certificate verification">Insecure TLS</abbr>
only affects forwarding to URLs like <kbd>https://...</kbd>
</label>
</div>
<div class="checkbox">
<label><input type="checkbox" id="basket_proxy_response">
<abbr title="Proxies the response from the forward URL back to the client">Proxy Response</abbr>
</label>
</div>
<div class="checkbox">
<label><input type="checkbox" id="basket_expand_path"> Expand Forward Path</label>
</div>
<div class="form-group">
<label for="basket_capacity" class="control-label">Basket Capacity:</label>
<input type="input" class="form-control" id="basket_capacity">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary">Apply</button>
</div>
</div>
</div>
</div>
</form>
<!-- Responses dialog -->
<form id="response_form">
<div class="modal fade" id="responses_dialog" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content panel-default">
<div class="modal-header panel-heading">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title" id="config_dialog_label">Basket Responses</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label for="response_method" class="control-label">HTTP method:</label>
<select class="form-control" id="response_method">
<option>GET</option>
<option>HEAD</option>
<option>POST</option>
<option>PUT</option>
<option>PATCH</option>
<option>DELETE</option>
<option>CONNECT</option>
<option>OPTIONS</option>
<option>TRACE</option>
</select>
</div>
<div class="form-group">
<label for="response_status" class="control-label">HTTP status:</label>
<input type="input" class="form-control" id="response_status">
</div>
<div class="form-group">
<label class="control-label">HTTP headers:</label>
<div id="response_headers">
<!-- response headers -->
</div>
</div>
<div class="form-group">
<label for="response_body" class="control-label">Response Body:</label>
<textarea class="form-control" id="response_body" rows="10"></textarea>
</div>
<div class="checkbox">
<label><input type="checkbox" id="response_is_template"> Process body as HTML template</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="update_response">Apply</button>
</div>
</div>
</div>
</div>
</form>
<!-- Destroy dialog -->
<div class="modal fade" id="destroy_dialog" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content panel-danger">
<div class="modal-header panel-heading">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Destroy This Basket</h4>
</div>
<div class="modal-body">
<p>Are you sure you want to <strong>permanently destroy</strong> this basket and delete all collected requests?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" id="destroy_confirmed">Destroy</button>
</div>
</div>
</div>
</div>
<!-- Error message -->
<div class="modal fade" id="error_message" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content panel-danger">
<div class="modal-header panel-heading">
<h4 class="modal-title" id="error_message_label">HTTP error</h4>
</div>
<div class="modal-body">
<p id="error_message_text"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-8">
<h1>Basket: {{.Basket}}</h1>
<p id="requests_link" class="hide">Requests are collected at <kbd class="basket_uri"></kbd>
<kbd class="copy-url-btn"><span title="Copy URL" class="glyphicon glyphicon-copy"></span></kbd></p>
</div>
<div class="col-md-3 col-md-offset-1">
<h4><abbr title="Current requests count (Total count)">Requests</abbr>: <span id="requests_count"></span></h4>
</div>
</div>
<hr/>
<div id="requests">
</div>
<div id="more" class="hide">
<button id="fetch_more" type="button" class="btn btn-default">
More <span id="more_count" class="badge"></span>
</button>
</div>
<!-- Empty basket -->
<div class="jumbotron text-center hide" id="empty_basket">
<h1>Empty basket!</h1>
<p>This basket is empty, send requests to <kbd class="basket_uri"></kbd>
<kbd class="copy-url-btn"><span title="Copy URL" class="glyphicon glyphicon-copy"></span></kbd> and they will appear here.</p>
</div>
</div>
<p> </p>
</body>
</html>`
)