UNPKG

11.9 kBHTMLView Raw
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <title>HttpTransportBuilder - Documentation</title>
6
7 <script src="scripts/prettify/prettify.js"></script>
8 <script src="scripts/prettify/lang-css.js"></script>
9 <!--[if lt IE 9]>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11 <![endif]-->
12 <link type="text/css" rel="stylesheet" href="styles/prettify.css">
13 <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
14 <meta name="viewport" content="width=device-width, initial-scale=1.0">
15</head>
16<body>
17
18<input type="checkbox" id="nav-trigger" class="nav-trigger" />
19<label for="nav-trigger" class="navicon-button x">
20 <div class="navicon"></div>
21</label>
22
23<label for="nav-trigger" class="overlay"></label>
24
25<nav>
26 <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="HttpTransportBuilder.html">HttpTransportBuilder</a><ul class='methods'><li data-type='method'><a href="HttpTransportBuilder.html#createClient">createClient</a></li><li data-type='method'><a href="HttpTransportBuilder.html#retries">retries</a></li><li data-type='method'><a href="HttpTransportBuilder.html#retryDelay">retryDelay</a></li><li data-type='method'><a href="HttpTransportBuilder.html#use">use</a></li><li data-type='method'><a href="HttpTransportBuilder.html#userAgent">userAgent</a></li></ul></li><li><a href="HttpTransportClient.html">HttpTransportClient</a><ul class='methods'><li data-type='method'><a href="HttpTransportClient.html#asBody">asBody</a></li><li data-type='method'><a href="HttpTransportClient.html#asResponse">asResponse</a></li><li data-type='method'><a href="HttpTransportClient.html#delete">delete</a></li><li data-type='method'><a href="HttpTransportClient.html#get">get</a></li><li data-type='method'><a href="HttpTransportClient.html#head">head</a></li><li data-type='method'><a href="HttpTransportClient.html#headers">headers</a></li><li data-type='method'><a href="HttpTransportClient.html#patch">patch</a></li><li data-type='method'><a href="HttpTransportClient.html#post">post</a></li><li data-type='method'><a href="HttpTransportClient.html#put">put</a></li><li data-type='method'><a href="HttpTransportClient.html#query">query</a></li><li data-type='method'><a href="HttpTransportClient.html#retry">retry</a></li><li data-type='method'><a href="HttpTransportClient.html#retryDelay">retryDelay</a></li><li data-type='method'><a href="HttpTransportClient.html#timeout">timeout</a></li><li data-type='method'><a href="HttpTransportClient.html#use">use</a></li></ul></li></ul>
27</nav>
28
29<div id="main">
30
31 <h1 class="page-title">HttpTransportBuilder</h1>
32
33
34
35
36
37
38
39<section>
40
41<header>
42
43 <h2>
44 HttpTransportBuilder
45 </h2>
46
47
48</header>
49
50<article>
51 <div class="container-overview">
52
53
54
55
56
57 <h4 class="name" id="HttpTransportBuilder"><span class="type-signature"></span>new HttpTransportBuilder<span class="signature">(transport)</span><span class="type-signature"></span></h4>
58
59
60
61
62
63
64<dl class="details">
65
66
67 <dt class="tag-source">Source:</dt>
68 <dd class="tag-source"><ul class="dummy"><li>
69 <a href="builder.js.html">builder.js</a>, <a href="builder.js.html#line12">line 12</a>
70 </li></ul></dd>
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</dl>
103
104
105
106
107
108<div class="description">
109 <p>Configures HttpTransport client</p>
110</div>
111
112
113
114
115
116
117
118
119
120
121
122 <h5>Parameters:</h5>
123
124
125<table class="params">
126 <thead>
127 <tr>
128
129 <th>Name</th>
130
131
132 <th>Type</th>
133
134
135
136
137
138 <th class="last">Description</th>
139 </tr>
140 </thead>
141
142 <tbody>
143
144
145 <tr>
146
147 <td class="name"><code>transport</code></td>
148
149
150 <td class="type">
151
152
153<span class="param-type">Transport</span>
154
155
156
157 </td>
158
159
160
161
162
163 <td class="description last"><p>Transport instance.</p></td>
164 </tr>
165
166
167 </tbody>
168</table>
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186 </div>
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201 <h3 class="subsection-title">Methods</h3>
202
203
204
205
206
207
208 <h4 class="name" id="createClient"><span class="type-signature"></span>createClient<span class="signature">()</span><span class="type-signature"></span></h4>
209
210
211
212
213
214
215<dl class="details">
216
217
218 <dt class="tag-source">Source:</dt>
219 <dd class="tag-source"><ul class="dummy"><li>
220 <a href="builder.js.html">builder.js</a>, <a href="builder.js.html#line98">line 98</a>
221 </li></ul></dd>
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</dl>
254
255
256
257
258
259<div class="description">
260 <p>Instantiates a HttpTransport</p>
261</div>
262
263
264
265
266
267
268
269
270
271 <h5>Example</h5>
272
273 <pre class="prettyprint"><code>const client = httpTransport.createClient();</code></pre>
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290<h5>Returns:</h5>
291
292
293<div class="param-desc">
294 <p>a HttpTransport instance</p>
295</div>
296
297
298
299
300
301
302
303
304
305
306
307 <h4 class="name" id="retries"><span class="type-signature"></span>retries<span class="signature">(retries)</span><span class="type-signature"></span></h4>
308
309
310
311
312
313
314<dl class="details">
315
316
317 <dt class="tag-source">Source:</dt>
318 <dd class="tag-source"><ul class="dummy"><li>
319 <a href="builder.js.html">builder.js</a>, <a href="builder.js.html#line51">line 51</a>
320 </li></ul></dd>
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</dl>
353
354
355
356
357
358<div class="description">
359 <p>Set the default number of retries</p>
360</div>
361
362
363
364
365
366
367
368
369
370 <h5>Example</h5>
371
372 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
373
374const builder = httpTransport.createBuilder();
375builder.retries(5);</code></pre>
376
377
378
379
380 <h5>Parameters:</h5>
381
382
383<table class="params">
384 <thead>
385 <tr>
386
387 <th>Name</th>
388
389
390 <th>Type</th>
391
392
393
394
395
396 <th class="last">Description</th>
397 </tr>
398 </thead>
399
400 <tbody>
401
402
403 <tr>
404
405 <td class="name"><code>retries</code></td>
406
407
408 <td class="type">
409
410
411<span class="param-type">integer</span>
412
413
414
415 </td>
416
417
418
419
420
421 <td class="description last"><p>number of retry attempts</p></td>
422 </tr>
423
424
425 </tbody>
426</table>
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441<h5>Returns:</h5>
442
443
444<div class="param-desc">
445 <p>a HttpTransportBuilder instance</p>
446</div>
447
448
449
450
451
452
453
454
455
456
457
458 <h4 class="name" id="retryDelay"><span class="type-signature"></span>retryDelay<span class="signature">(delay)</span><span class="type-signature"></span></h4>
459
460
461
462
463
464
465<dl class="details">
466
467
468 <dt class="tag-source">Source:</dt>
469 <dd class="tag-source"><ul class="dummy"><li>
470 <a href="builder.js.html">builder.js</a>, <a href="builder.js.html#line67">line 67</a>
471 </li></ul></dd>
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</dl>
504
505
506
507
508
509<div class="description">
510 <p>default time delay between retries</p>
511</div>
512
513
514
515
516
517
518
519
520
521 <h5>Example</h5>
522
523 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
524
525const builder = httpTransport.createBuilder();
526builder.retryDelay(1000);</code></pre>
527
528
529
530
531 <h5>Parameters:</h5>
532
533
534<table class="params">
535 <thead>
536 <tr>
537
538 <th>Name</th>
539
540
541 <th>Type</th>
542
543
544
545
546
547 <th class="last">Description</th>
548 </tr>
549 </thead>
550
551 <tbody>
552
553
554 <tr>
555
556 <td class="name"><code>delay</code></td>
557
558
559 <td class="type">
560
561
562<span class="param-type">integer</span>
563
564
565
566 </td>
567
568
569
570
571
572 <td class="description last"><p>delay time in ms</p></td>
573 </tr>
574
575
576 </tbody>
577</table>
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592<h5>Returns:</h5>
593
594
595<div class="param-desc">
596 <p>a HttpTransportBuilder instance</p>
597</div>
598
599
600
601
602
603
604
605
606
607
608
609 <h4 class="name" id="use"><span class="type-signature"></span>use<span class="signature">(fn)</span><span class="type-signature"></span></h4>
610
611
612
613
614
615
616<dl class="details">
617
618
619 <dt class="tag-source">Source:</dt>
620 <dd class="tag-source"><ul class="dummy"><li>
621 <a href="builder.js.html">builder.js</a>, <a href="builder.js.html#line84">line 84</a>
622 </li></ul></dd>
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</dl>
655
656
657
658
659
660<div class="description">
661 <p>Registers a global plugin, which is used for all requests</p>
662</div>
663
664
665
666
667
668
669
670
671
672 <h5>Example</h5>
673
674 <pre class="prettyprint"><code>const toError = require('@bbc/http-transport-errors');
675const httpTransport = require('@bbc/http-transport');
676
677const client = httpTransport.createClient();
678client.useGlobal(toError(404));</code></pre>
679
680
681
682
683 <h5>Parameters:</h5>
684
685
686<table class="params">
687 <thead>
688 <tr>
689
690 <th>Name</th>
691
692
693 <th>Type</th>
694
695
696
697
698
699 <th class="last">Description</th>
700 </tr>
701 </thead>
702
703 <tbody>
704
705
706 <tr>
707
708 <td class="name"><code>fn</code></td>
709
710
711 <td class="type">
712
713
714<span class="param-type">function</span>
715
716
717
718 </td>
719
720
721
722
723
724 <td class="description last"><p>a global plugin</p></td>
725 </tr>
726
727
728 </tbody>
729</table>
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744<h5>Returns:</h5>
745
746
747<div class="param-desc">
748 <p>a HttpTransportBuilder instance</p>
749</div>
750
751
752
753
754
755
756
757
758
759
760
761 <h4 class="name" id="userAgent"><span class="type-signature"></span>userAgent<span class="signature">(agent)</span><span class="type-signature"></span></h4>
762
763
764
765
766
767
768<dl class="details">
769
770
771 <dt class="tag-source">Source:</dt>
772 <dd class="tag-source"><ul class="dummy"><li>
773 <a href="builder.js.html">builder.js</a>, <a href="builder.js.html#line35">line 35</a>
774 </li></ul></dd>
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</dl>
807
808
809
810
811
812<div class="description">
813 <p>Sets a default user agent</p>
814</div>
815
816
817
818
819
820
821
822
823
824 <h5>Example</h5>
825
826 <pre class="prettyprint"><code>const httpTransport = require('@bbc/http-transport');
827
828const builder = httpTransport.createBuilder();
829builder.userAgent('some-user-agent');</code></pre>
830
831
832
833
834 <h5>Parameters:</h5>
835
836
837<table class="params">
838 <thead>
839 <tr>
840
841 <th>Name</th>
842
843
844 <th>Type</th>
845
846
847
848
849
850 <th class="last">Description</th>
851 </tr>
852 </thead>
853
854 <tbody>
855
856
857 <tr>
858
859 <td class="name"><code>agent</code></td>
860
861
862 <td class="type">
863
864
865<span class="param-type">string</span>
866
867
868
869 </td>
870
871
872
873
874
875 <td class="description last"><p>user agent</p></td>
876 </tr>
877
878
879 </tbody>
880</table>
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895<h5>Returns:</h5>
896
897
898<div class="param-desc">
899 <p>a HttpTransportBuilder instance</p>
900</div>
901
902
903
904
905
906
907
908
909
910
911
912
913</article>
914
915</section>
916
917
918
919
920</div>
921
922<br class="clear">
923
924<footer>
925 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Fri Sep 22 2023 15:20:00 GMT+0100 (British Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
926</footer>
927
928<script>prettyPrint();</script>
929<script src="scripts/linenumber.js"></script>
930</body>
931</html>
\No newline at end of file