Merge pull request #4200 from zhanhb/luci-app-acme
[project/luci.git] / docs / api / modules / luci.dispatcher.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html>
4 <head>
5 <title>Reference</title>
6 <link rel="stylesheet" href="../luadoc.css" type="text/css" />
7 <!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
8 </head>
9
10 <body>
11 <div id="container">
12
13 <div id="product">
14 <div id="product_logo"></div>
15 <div id="product_name"><big><b></b></big></div>
16 <div id="product_description"></div>
17 </div> <!-- id="product" -->
18
19 <div id="main">
20
21 <div id="navigation">
22
23
24 <h1>LuaDoc</h1>
25 <ul>
26
27 <li><a href="../index.html">Index</a></li>
28
29 </ul>
30
31
32 <!-- Module list -->
33
34 <h1>Modules</h1>
35 <ul>
36
37 <li><strong>luci.dispatcher</strong></li>
38
39 <li>
40 <a href="../modules/luci.http.html">luci.http</a>
41 </li>
42
43 <li>
44 <a href="../modules/luci.http.conditionals.html">luci.http.conditionals</a>
45 </li>
46
47 <li>
48 <a href="../modules/luci.http.date.html">luci.http.date</a>
49 </li>
50
51 <li>
52 <a href="../modules/luci.http.mime.html">luci.http.mime</a>
53 </li>
54
55 <li>
56 <a href="../modules/luci.i18n.html">luci.i18n</a>
57 </li>
58
59 <li>
60 <a href="../modules/luci.ip.html">luci.ip</a>
61 </li>
62
63 <li>
64 <a href="../modules/luci.ip.cidr.html">luci.ip.cidr</a>
65 </li>
66
67 <li>
68 <a href="../modules/luci.json.html">luci.json</a>
69 </li>
70
71 <li>
72 <a href="../modules/luci.jsonc.html">luci.jsonc</a>
73 </li>
74
75 <li>
76 <a href="../modules/luci.jsonc.parser.html">luci.jsonc.parser</a>
77 </li>
78
79 <li>
80 <a href="../modules/luci.model.ipkg.html">luci.model.ipkg</a>
81 </li>
82
83 <li>
84 <a href="../modules/luci.model.uci.html">luci.model.uci</a>
85 </li>
86
87 <li>
88 <a href="../modules/luci.rpcc.html">luci.rpcc</a>
89 </li>
90
91 <li>
92 <a href="../modules/luci.rpcc.ruci.html">luci.rpcc.ruci</a>
93 </li>
94
95 <li>
96 <a href="../modules/luci.sys.html">luci.sys</a>
97 </li>
98
99 <li>
100 <a href="../modules/luci.sys.init.html">luci.sys.init</a>
101 </li>
102
103 <li>
104 <a href="../modules/luci.sys.iptparser.html">luci.sys.iptparser</a>
105 </li>
106
107 <li>
108 <a href="../modules/luci.sys.net.html">luci.sys.net</a>
109 </li>
110
111 <li>
112 <a href="../modules/luci.sys.process.html">luci.sys.process</a>
113 </li>
114
115 <li>
116 <a href="../modules/luci.sys.user.html">luci.sys.user</a>
117 </li>
118
119 <li>
120 <a href="../modules/luci.sys.wifi.html">luci.sys.wifi</a>
121 </li>
122
123 <li>
124 <a href="../modules/luci.util.html">luci.util</a>
125 </li>
126
127 <li>
128 <a href="../modules/luci.xml.html">luci.xml</a>
129 </li>
130
131 <li>
132 <a href="../modules/nixio.html">nixio</a>
133 </li>
134
135 <li>
136 <a href="../modules/nixio.CHANGELOG.html">nixio.CHANGELOG</a>
137 </li>
138
139 <li>
140 <a href="../modules/nixio.CryptoHash.html">nixio.CryptoHash</a>
141 </li>
142
143 <li>
144 <a href="../modules/nixio.File.html">nixio.File</a>
145 </li>
146
147 <li>
148 <a href="../modules/nixio.README.html">nixio.README</a>
149 </li>
150
151 <li>
152 <a href="../modules/nixio.Socket.html">nixio.Socket</a>
153 </li>
154
155 <li>
156 <a href="../modules/nixio.TLSContext.html">nixio.TLSContext</a>
157 </li>
158
159 <li>
160 <a href="../modules/nixio.TLSSocket.html">nixio.TLSSocket</a>
161 </li>
162
163 <li>
164 <a href="../modules/nixio.UnifiedIO.html">nixio.UnifiedIO</a>
165 </li>
166
167 <li>
168 <a href="../modules/nixio.bin.html">nixio.bin</a>
169 </li>
170
171 <li>
172 <a href="../modules/nixio.bit.html">nixio.bit</a>
173 </li>
174
175 <li>
176 <a href="../modules/nixio.crypto.html">nixio.crypto</a>
177 </li>
178
179 <li>
180 <a href="../modules/nixio.fs.html">nixio.fs</a>
181 </li>
182
183 </ul>
184
185
186
187 <!-- File list -->
188
189
190
191
192
193
194
195 </div><!-- id="navigation" -->
196
197 <div id="content">
198
199 <h1>Class <code>luci.dispatcher</code></h1>
200
201 <p></p>
202
203
204
205
206
207
208
209 <h2>Functions</h2>
210 <table class="function_list">
211
212 <tr>
213 <td class="name" nowrap><a href="#_">_</a>&nbsp;()</td>
214 <td class="summary">
215
216 No-op function used to mark translation entries for menu labels.</td>
217 </tr>
218
219 <tr>
220 <td class="name" nowrap><a href="#alias">alias</a>&nbsp;(...)</td>
221 <td class="summary">
222
223 Create a redirect to another dispatching node.</td>
224 </tr>
225
226 <tr>
227 <td class="name" nowrap><a href="#arcombine">arcombine</a>&nbsp;(trg1, trg2)</td>
228 <td class="summary">
229
230 Create a combined dispatching target for non argv and argv requests.</td>
231 </tr>
232
233 <tr>
234 <td class="name" nowrap><a href="#assign">assign</a>&nbsp;(path, clone, title, order)</td>
235 <td class="summary">
236
237 Clone a node of the dispatching tree to another position.</td>
238 </tr>
239
240 <tr>
241 <td class="name" nowrap><a href="#build_url">build_url</a>&nbsp;(...)</td>
242 <td class="summary">
243
244 Build the URL relative to the server webroot from given virtual path.</td>
245 </tr>
246
247 <tr>
248 <td class="name" nowrap><a href="#call">call</a>&nbsp;(name, ...)</td>
249 <td class="summary">
250
251 Create a function-call dispatching target.</td>
252 </tr>
253
254 <tr>
255 <td class="name" nowrap><a href="#cbi">cbi</a>&nbsp;(model)</td>
256 <td class="summary">
257
258 Create a CBI model dispatching target.</td>
259 </tr>
260
261 <tr>
262 <td class="name" nowrap><a href="#createindex">createindex</a>&nbsp;()</td>
263 <td class="summary">
264
265 Generate the dispatching index using the native file-cache based strategy.</td>
266 </tr>
267
268 <tr>
269 <td class="name" nowrap><a href="#createtree">createtree</a>&nbsp;()</td>
270 <td class="summary">
271
272 Create the dispatching tree from the index.</td>
273 </tr>
274
275 <tr>
276 <td class="name" nowrap><a href="#dispatch">dispatch</a>&nbsp;(request)</td>
277 <td class="summary">
278
279 Dispatches a LuCI virtual path.</td>
280 </tr>
281
282 <tr>
283 <td class="name" nowrap><a href="#entry">entry</a>&nbsp;(path, target, title, order)</td>
284 <td class="summary">
285
286 Create a new dispatching node and define common parameters.</td>
287 </tr>
288
289 <tr>
290 <td class="name" nowrap><a href="#error404">error404</a>&nbsp;(message)</td>
291 <td class="summary">
292
293 Send a 404 error code and render the "error404" template if available.</td>
294 </tr>
295
296 <tr>
297 <td class="name" nowrap><a href="#error500">error500</a>&nbsp;(message)</td>
298 <td class="summary">
299
300 Send a 500 error code and render the "error500" template if available.</td>
301 </tr>
302
303 <tr>
304 <td class="name" nowrap><a href="#firstchild">firstchild</a>&nbsp;()</td>
305 <td class="summary">
306
307 Alias the first (lowest order) page automatically
308
309 </td>
310 </tr>
311
312 <tr>
313 <td class="name" nowrap><a href="#form">form</a>&nbsp;(model)</td>
314 <td class="summary">
315
316 Create a CBI form model dispatching target.</td>
317 </tr>
318
319 <tr>
320 <td class="name" nowrap><a href="#get">get</a>&nbsp;(...)</td>
321 <td class="summary">
322
323 Fetch or create a dispatching node without setting the target module or
324 enabling the node.</td>
325 </tr>
326
327 <tr>
328 <td class="name" nowrap><a href="#httpdispatch">httpdispatch</a>&nbsp;(request)</td>
329 <td class="summary">
330
331 Dispatch an HTTP request.</td>
332 </tr>
333
334 <tr>
335 <td class="name" nowrap><a href="#lookup">lookup</a>&nbsp;(...)</td>
336 <td class="summary">
337
338 Lookup node in dispatching tree.</td>
339 </tr>
340
341 <tr>
342 <td class="name" nowrap><a href="#node">node</a>&nbsp;(...)</td>
343 <td class="summary">
344
345 Fetch or create a new dispatching node.</td>
346 </tr>
347
348 <tr>
349 <td class="name" nowrap><a href="#node_childs">node_childs</a>&nbsp;(node)</td>
350 <td class="summary">
351
352 Return a sorted table of visible children within a given node
353 </td>
354 </tr>
355
356 <tr>
357 <td class="name" nowrap><a href="#node_visible">node_visible</a>&nbsp;(node)</td>
358 <td class="summary">
359
360 Check whether a dispatch node shall be visible
361 </td>
362 </tr>
363
364 <tr>
365 <td class="name" nowrap><a href="#rewrite">rewrite</a>&nbsp;(n, ...)</td>
366 <td class="summary">
367
368 Rewrite the first x path values of the request.</td>
369 </tr>
370
371 <tr>
372 <td class="name" nowrap><a href="#template">template</a>&nbsp;(name)</td>
373 <td class="summary">
374
375 Create a template render dispatching target.</td>
376 </tr>
377
378 <tr>
379 <td class="name" nowrap><a href="#translate">translate</a>&nbsp;(text)</td>
380 <td class="summary">
381
382 Access the luci.i18n translate() api.</td>
383 </tr>
384
385 </table>
386
387
388
389
390
391
392 <br/>
393 <br/>
394
395
396 <h2><a name="functions"></a>Functions</h2>
397 <dl class="function">
398
399
400
401 <dt><a name="_"></a><strong>_</strong>&nbsp;()</dt>
402 <dd>
403
404
405 No-op function used to mark translation entries for menu labels.
406
407 This function does not actually translate the given argument but
408 is used by build/i18n-scan.pl to find translatable entries.
409
410
411
412
413
414
415
416
417
418
419 </dd>
420
421
422
423
424 <dt><a name="alias"></a><strong>alias</strong>&nbsp;(...)</dt>
425 <dd>
426
427
428 Create a redirect to another dispatching node.
429
430
431
432 <h3>Parameters</h3>
433 <ul>
434
435 <li>
436 ...: Virtual path destination
437 </li>
438
439 </ul>
440
441
442
443
444
445
446
447
448 </dd>
449
450
451
452
453 <dt><a name="arcombine"></a><strong>arcombine</strong>&nbsp;(trg1, trg2)</dt>
454 <dd>
455
456
457 Create a combined dispatching target for non argv and argv requests.
458
459
460
461 <h3>Parameters</h3>
462 <ul>
463
464 <li>
465 trg1: Overview Target
466 </li>
467
468 <li>
469 trg2: Detail Target
470 </li>
471
472 </ul>
473
474
475
476
477
478
479
480
481 </dd>
482
483
484
485
486 <dt><a name="assign"></a><strong>assign</strong>&nbsp;(path, clone, title, order)</dt>
487 <dd>
488
489
490 Clone a node of the dispatching tree to another position.
491
492
493
494 <h3>Parameters</h3>
495 <ul>
496
497 <li>
498 path: Virtual path destination
499 </li>
500
501 <li>
502 clone: Virtual path source
503 </li>
504
505 <li>
506 title: Destination node title (optional)
507 </li>
508
509 <li>
510 order: Destination node order value (optional)
511 </li>
512
513 </ul>
514
515
516
517
518
519
520 <h3>Return value:</h3>
521 Dispatching tree node
522
523
524
525 </dd>
526
527
528
529
530 <dt><a name="build_url"></a><strong>build_url</strong>&nbsp;(...)</dt>
531 <dd>
532
533
534 Build the URL relative to the server webroot from given virtual path.
535
536
537
538 <h3>Parameters</h3>
539 <ul>
540
541 <li>
542 ...: Virtual path
543 </li>
544
545 </ul>
546
547
548
549
550
551
552 <h3>Return value:</h3>
553 Relative URL
554
555
556
557 </dd>
558
559
560
561
562 <dt><a name="call"></a><strong>call</strong>&nbsp;(name, ...)</dt>
563 <dd>
564
565
566 Create a function-call dispatching target.
567
568
569
570 <h3>Parameters</h3>
571 <ul>
572
573 <li>
574 name: Target function of local controller
575 </li>
576
577 <li>
578 ...: Additional parameters passed to the function
579 </li>
580
581 </ul>
582
583
584
585
586
587
588
589
590 </dd>
591
592
593
594
595 <dt><a name="cbi"></a><strong>cbi</strong>&nbsp;(model)</dt>
596 <dd>
597
598
599 Create a CBI model dispatching target.
600
601
602
603 <h3>Parameters</h3>
604 <ul>
605
606 <li>
607 model: CBI model to be rendered
608 </li>
609
610 </ul>
611
612
613
614
615
616
617
618
619 </dd>
620
621
622
623
624 <dt><a name="createindex"></a><strong>createindex</strong>&nbsp;()</dt>
625 <dd>
626
627
628 Generate the dispatching index using the native file-cache based strategy.
629
630
631
632
633
634
635
636
637
638
639
640 </dd>
641
642
643
644
645 <dt><a name="createtree"></a><strong>createtree</strong>&nbsp;()</dt>
646 <dd>
647
648
649 Create the dispatching tree from the index.
650
651 Build the index before if it does not exist yet.
652
653
654
655
656
657
658
659
660
661
662 </dd>
663
664
665
666
667 <dt><a name="dispatch"></a><strong>dispatch</strong>&nbsp;(request)</dt>
668 <dd>
669
670
671 Dispatches a LuCI virtual path.
672
673
674
675 <h3>Parameters</h3>
676 <ul>
677
678 <li>
679 request: Virtual path
680 </li>
681
682 </ul>
683
684
685
686
687
688
689
690
691 </dd>
692
693
694
695
696 <dt><a name="entry"></a><strong>entry</strong>&nbsp;(path, target, title, order)</dt>
697 <dd>
698
699
700 Create a new dispatching node and define common parameters.
701
702
703
704 <h3>Parameters</h3>
705 <ul>
706
707 <li>
708 path: Virtual path
709 </li>
710
711 <li>
712 target: Target function to call when dispatched.
713 </li>
714
715 <li>
716 title: Destination node title
717 </li>
718
719 <li>
720 order: Destination node order value (optional)
721 </li>
722
723 </ul>
724
725
726
727
728
729
730 <h3>Return value:</h3>
731 Dispatching tree node
732
733
734
735 </dd>
736
737
738
739
740 <dt><a name="error404"></a><strong>error404</strong>&nbsp;(message)</dt>
741 <dd>
742
743
744 Send a 404 error code and render the "error404" template if available.
745
746
747
748 <h3>Parameters</h3>
749 <ul>
750
751 <li>
752 message: Custom error message (optional)
753 </li>
754
755 </ul>
756
757
758
759
760
761
762 <h3>Return value:</h3>
763 false
764
765
766
767 </dd>
768
769
770
771
772 <dt><a name="error500"></a><strong>error500</strong>&nbsp;(message)</dt>
773 <dd>
774
775
776 Send a 500 error code and render the "error500" template if available.
777
778
779
780 <h3>Parameters</h3>
781 <ul>
782
783 <li>
784 message: Custom error message (optional)#
785 </li>
786
787 </ul>
788
789
790
791
792
793
794 <h3>Return value:</h3>
795 false
796
797
798
799 </dd>
800
801
802
803
804 <dt><a name="firstchild"></a><strong>firstchild</strong>&nbsp;()</dt>
805 <dd>
806
807
808 Alias the first (lowest order) page automatically
809
810
811
812
813
814
815
816
817
818
819
820 </dd>
821
822
823
824
825 <dt><a name="form"></a><strong>form</strong>&nbsp;(model)</dt>
826 <dd>
827
828
829 Create a CBI form model dispatching target.
830
831
832
833 <h3>Parameters</h3>
834 <ul>
835
836 <li>
837 model: CBI form model tpo be rendered
838 </li>
839
840 </ul>
841
842
843
844
845
846
847
848
849 </dd>
850
851
852
853
854 <dt><a name="get"></a><strong>get</strong>&nbsp;(...)</dt>
855 <dd>
856
857
858 Fetch or create a dispatching node without setting the target module or
859 enabling the node.
860
861
862
863 <h3>Parameters</h3>
864 <ul>
865
866 <li>
867 ...: Virtual path
868 </li>
869
870 </ul>
871
872
873
874
875
876
877 <h3>Return value:</h3>
878 Dispatching tree node
879
880
881
882 </dd>
883
884
885
886
887 <dt><a name="httpdispatch"></a><strong>httpdispatch</strong>&nbsp;(request)</dt>
888 <dd>
889
890
891 Dispatch an HTTP request.
892
893
894
895 <h3>Parameters</h3>
896 <ul>
897
898 <li>
899 request: LuCI HTTP Request object
900 </li>
901
902 </ul>
903
904
905
906
907
908
909
910
911 </dd>
912
913
914
915
916 <dt><a name="lookup"></a><strong>lookup</strong>&nbsp;(...)</dt>
917 <dd>
918
919
920 Lookup node in dispatching tree.
921
922
923
924 <h3>Parameters</h3>
925 <ul>
926
927 <li>
928 ...: Virtual path
929 </li>
930
931 </ul>
932
933
934
935
936
937
938 <h3>Return value:</h3>
939 Node object, canonical url or nil if the path was not found.
940
941
942
943 </dd>
944
945
946
947
948 <dt><a name="node"></a><strong>node</strong>&nbsp;(...)</dt>
949 <dd>
950
951
952 Fetch or create a new dispatching node.
953
954
955
956 <h3>Parameters</h3>
957 <ul>
958
959 <li>
960 ...: Virtual path
961 </li>
962
963 </ul>
964
965
966
967
968
969
970 <h3>Return value:</h3>
971 Dispatching tree node
972
973
974
975 </dd>
976
977
978
979
980 <dt><a name="node_childs"></a><strong>node_childs</strong>&nbsp;(node)</dt>
981 <dd>
982
983
984 Return a sorted table of visible children within a given node
985
986
987
988 <h3>Parameters</h3>
989 <ul>
990
991 <li>
992 node: Dispatch node
993 </li>
994
995 </ul>
996
997
998
999
1000
1001
1002 <h3>Return value:</h3>
1003 Ordered table of child node names
1004
1005
1006
1007 </dd>
1008
1009
1010
1011
1012 <dt><a name="node_visible"></a><strong>node_visible</strong>&nbsp;(node)</dt>
1013 <dd>
1014
1015
1016 Check whether a dispatch node shall be visible
1017
1018
1019
1020 <h3>Parameters</h3>
1021 <ul>
1022
1023 <li>
1024 node: Dispatch node
1025 </li>
1026
1027 </ul>
1028
1029
1030
1031
1032
1033
1034 <h3>Return value:</h3>
1035 Boolean indicating whether the node should be visible
1036
1037
1038
1039 </dd>
1040
1041
1042
1043
1044 <dt><a name="rewrite"></a><strong>rewrite</strong>&nbsp;(n, ...)</dt>
1045 <dd>
1046
1047
1048 Rewrite the first x path values of the request.
1049
1050
1051
1052 <h3>Parameters</h3>
1053 <ul>
1054
1055 <li>
1056 n: Number of path values to replace
1057 </li>
1058
1059 <li>
1060 ...: Virtual path to replace removed path values with
1061 </li>
1062
1063 </ul>
1064
1065
1066
1067
1068
1069
1070
1071
1072 </dd>
1073
1074
1075
1076
1077 <dt><a name="template"></a><strong>template</strong>&nbsp;(name)</dt>
1078 <dd>
1079
1080
1081 Create a template render dispatching target.
1082
1083
1084
1085 <h3>Parameters</h3>
1086 <ul>
1087
1088 <li>
1089 name: Template to be rendered
1090 </li>
1091
1092 </ul>
1093
1094
1095
1096
1097
1098
1099
1100
1101 </dd>
1102
1103
1104
1105
1106 <dt><a name="translate"></a><strong>translate</strong>&nbsp;(text)</dt>
1107 <dd>
1108
1109
1110 Access the luci.i18n translate() api.
1111
1112
1113
1114 <h3>Parameters</h3>
1115 <ul>
1116
1117 <li>
1118 text: Text to translate
1119 </li>
1120
1121 </ul>
1122
1123
1124
1125
1126
1127
1128
1129
1130 </dd>
1131
1132
1133 </dl>
1134
1135
1136
1137
1138
1139 </div> <!-- id="content" -->
1140
1141 </div> <!-- id="main" -->
1142
1143 <div id="about">
1144 <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
1145 </div> <!-- id="about" -->
1146
1147 </div> <!-- id="container" -->
1148 </body>
1149 </html>