Web Route example

# Path Type Permissions Auth Controller
1 [GET] / WEB [] false HomeController
2 [POST] / WEB [] false HomeController
3 [PUT] / WEB [] false HomeController
4 [HEAD] / WEB [] false HomeController
5 [DELETE] / WEB [] false HomeController
6 [INSERT] / WEB [] false HomeController
7 [CONNECT] / WEB [] false HomeController
8 [OPTIONS] / WEB [] false HomeController
9 [TRACE] / WEB [] false HomeController
10 [PATCH] / WEB [] false HomeController
11 [GET] /api/docs/ API [] false Future
12 [GET] /api/info/ API [] false info
13 [DELETE] /app/includes.js/ WEB [] false index
14 [GET] /app/includes.js/ WEB [] false index
15 [POST] /app/includes.js/ WEB [] false index
16 [PUT] /app/includes.js/ WEB [] false index
17 [HEAD] /app/includes.js/ WEB [] false index
18 [INSERT] /app/includes.js/ WEB [] false index
19 [CONNECT] /app/includes.js/ WEB [] false index
20 [OPTIONS] /app/includes.js/ WEB [] false index
21 [TRACE] /app/includes.js/ WEB [] false index
22 [PATCH] /app/includes.js/ WEB [] false index
23 [GET] /ar/*/ WEB [] false changeLanguage
24 [GET] /de/*/ WEB [] false changeLanguage
25 [GET] /en/*/ WEB [] false changeLanguage
26 [GET] /es/*/ WEB [] false changeLanguage
27 [GET] /example/ WEB [] false Future
28 [GET] /example/cookie/ WEB [] false exampleCookie
29 [POST] /example/cookie/ WEB [] false exampleAddCookie
30 [GET] /example/cookie/ WEB [] false exampleAddCookie
31 [GET] /example/database/ WEB [] false exampleDatabase
32 [POST] /example/database/ WEB [] false exampleDatabase
33 [PUT] /example/database/ WEB [] false exampleDatabase
34 [DELETE] /example/database/ WEB [] false exampleDatabase
35 [GET] /example/dump/ WEB [] false exampleDump
36 [GET] /example/email/ WEB [] false exampleEmail
37 [POST] /example/email/ WEB [] false exampleEmailSend
38 [GET] /example/error/ WEB [] false exampleError
39 [GET] /example/form/ WEB [] false exampleForm
40 [POST] /example/form/ WEB [] false loginPost
41 [PATCH] /example/host/ WEB [] false Future
42 [OPTIONS] /example/host/ WEB [] false Future
43 [PATCH] /example/host/ WEB [] false Future
44 [GET] /example/host/ WEB [] false Future
45 [POST] /example/host/ WEB [] false Future
46 [PUT] /example/host/ WEB [] false Future
47 [HEAD] /example/host/ WEB [] false Future
48 [DELETE] /example/host/ WEB [] false Future
49 [INSERT] /example/host/ WEB [] false Future
50 [CONNECT] /example/host/ WEB [] false Future
51 [OPTIONS] /example/host/ WEB [] false Future
52 [TRACE] /example/host/ WEB [] false Future
53 [CONNECT] /example/host/ WEB [] false Future
54 [INSERT] /example/host/ WEB [] false Future
55 [DELETE] /example/host/ WEB [] false Future
56 [HEAD] /example/host/ WEB [] false Future
57 [GET] /example/host/ WEB [] false Future
58 [TRACE] /example/host/ WEB [] false Future
59 [PUT] /example/host/ WEB [] false Future
60 [POST] /example/host/ WEB [] false Future
61 [GET] /example/language/ WEB [] false exampleLanguage
62 [GET] /example/pagination/ WEB [] false paginationExample
63 [CONNECT] /example/panel/ WEB [admin] true exampleAuth
64 [OPTIONS] /example/panel/ WEB [admin] true exampleAuth
65 [TRACE] /example/panel/ WEB [admin] true exampleAuth
66 [PATCH] /example/panel/ WEB [admin] true exampleAuth
67 [DELETE] /example/panel/ WEB [admin] true exampleAuth
68 [HEAD] /example/panel/ WEB [admin] true exampleAuth
69 [POST] /example/panel/ WEB [admin] true exampleAuth
70 [GET] /example/panel/ WEB [admin] true exampleAuth
71 [PUT] /example/panel/ WEB [admin] true exampleAuth
72 [INSERT] /example/panel/ WEB [admin] true exampleAuth
73 [GET] /example/route/ WEB [] false exampleRoute
74 [GET] /example/socket/ WEB [] false exampleSocket
75 [GET] /fa/*/ WEB [] false changeLanguage
76 [GET] /fa/*/ WEB [] false changeLanguage
77 [GET] /fr/*/ WEB [] false changeLanguage
78 [GET] /info/ WEB [] false info
79 [GET] /it/*/ WEB [] false changeLanguage
80 [GET] /ja/*/ WEB [] false changeLanguage
81 [GET] /ko/*/ WEB [] false changeLanguage
82 [OPTIONS] /logout/ WEB [] false logout
83 [PATCH] /logout/ WEB [] false logout
84 [GET] /logout/ WEB [] false logout
85 [POST] /logout/ WEB [] false logout
86 [PUT] /logout/ WEB [] false logout
87 [HEAD] /logout/ WEB [] false logout
88 [DELETE] /logout/ WEB [] false logout
89 [INSERT] /logout/ WEB [] false logout
90 [TRACE] /logout/ WEB [] false logout
91 [CONNECT] /logout/ WEB [] false logout
92 [GET] /nl/*/ WEB [] false changeLanguage
93 [GET] /ru/*/ WEB [] false changeLanguage
94 [GET] /swagger/ WEB [] false Future
95 [GET] /tr/*/ WEB [] false changeLanguage
96 [PATCH] /ws/ WEB [] false socket
97 [TRACE] /ws/ WEB [] false socket
98 [OPTIONS] /ws/ WEB [] false socket
99 [CONNECT] /ws/ WEB [] false socket
100 [DELETE] /ws/ WEB [] false socket
101 [HEAD] /ws/ WEB [] false socket
102 [PUT] /ws/ WEB [] false socket
103 [POST] /ws/ WEB [] false socket
104 [GET] /ws/ WEB [] false socket
105 [INSERT] /ws/ WEB [] false socket
106 [GET] /zh/*/ WEB [] false changeLanguage
  • Router example/lib/route/web_route.dart
        
import 'package:webapp/wa_route.dart';
import '../controllers/home_controller.dart';

Future> getWebRoute(WebRequest rq) async {
  final homeController = HomeController(rq);
  final includeController = IncludeJsController(rq);

  var paths = [
    WebRoute(
      path: 'ws',
      methods: RequestMethods.ALL,
      rq: rq,
      index: homeController.socket,
    ),
    WebRoute(
      path: 'app/includes.js',
      methods: RequestMethods.ALL,
      rq: rq,
      index: includeController.index,
    ),
    WebRoute(
      path: 'example',
      rq: rq,
      index: () => rq.redirect('/'),
      children: [
        WebRoute(
          path: '/form',
          methods: RequestMethods.ALL,
          rq: rq,
          index: homeController.exampleForm,
        ),
        WebRoute(
          path: '/cookie',
          methods: RequestMethods.ONLY_GET,
          rq: rq,
          index: homeController.exampleCookie,
        ),
        WebRoute(
          path: '/cookie',
          methods: RequestMethods.ONLY_POST,
          rq: rq,
          index: homeController.exampleAddCookie,
        ),
        WebRoute(
          path: '/cookie',
          methods: RequestMethods.ONLY_GET,
          rq: rq,
          index: homeController.exampleAddCookie,
        ),
        WebRoute(
          path: '/route',
          methods: RequestMethods.ONLY_GET,
          rq: rq,
          index: homeController.exampleRoute,
        ),
        WebRoute(
          path: '/socket',
          methods: RequestMethods.ONLY_GET,
          rq: rq,
          index: homeController.exampleSocket,
        ),
        WebRoute(
          path: '/email',
          methods: RequestMethods.ONLY_GET,
          rq: rq,
          index: homeController.exampleEmail,
        ),
        WebRoute(
          path: '/email',
          methods: RequestMethods.ONLY_POST,
          rq: rq,
          index: homeController.exampleEmailSend,
        ),
      ],
    ),
    WebRoute(
      path: 'info',
      extraPath: ['api/info'],
      rq: rq,
      index: homeController.info,
    ),
  ];

  return [
    WebRoute(
      path: '/',
      rq: rq,
      methods: RequestMethods.ALL,
      controller: homeController,
      children: [
        ...paths,
        WebRoute(
          path: 'fa/*',
          extraPath: [
            'en/*',
            'nl/*',
          ],
          rq: rq,
          index: homeController.changeLanguage,
        )
      ],
    ),
  ];
}