Web Route example

# Path Type Permissions Auth Controller
1 [POST] / WEB [] false HomeController
2 [PUT] / WEB [] false HomeController
3 [HEAD] / WEB [] false HomeController
4 [DELETE] / WEB [] false HomeController
5 [INSERT] / WEB [] false HomeController
6 [CONNECT] / WEB [] false HomeController
7 [OPTIONS] / WEB [] false HomeController
8 [TRACE] / WEB [] false HomeController
9 [PATCH] / WEB [] false HomeController
10 [GET] / WEB [] false HomeController
11 [GET] /api/docs/ API [] false Future
12 [GET] /api/info/ API [] false info
13 [POST] /api/person/ API [] false addNewPerson
14 [POST] /api/person/replace/{id}/ API [] false replacePerson
15 [DELETE] /api/person/{id}/ API [] false deletePerson
16 [POST] /api/person/{id}/ API [] false updateOrDeletePerson
17 [GET] /api/person/{id}/ API [] false onePerson
18 [GET] /api/persons/ API [] false allPerson
19 [CONNECT] /app/includes.js/ WEB [] false index
20 [HEAD] /app/includes.js/ WEB [] false index
21 [DELETE] /app/includes.js/ WEB [] false index
22 [INSERT] /app/includes.js/ WEB [] false index
23 [OPTIONS] /app/includes.js/ WEB [] false index
24 [TRACE] /app/includes.js/ WEB [] false index
25 [PATCH] /app/includes.js/ WEB [] false index
26 [GET] /app/includes.js/ WEB [] false index
27 [POST] /app/includes.js/ WEB [] false index
28 [PUT] /app/includes.js/ WEB [] false index
29 [GET] /ar/*/ WEB [] false changeLanguage
30 [GET] /de/*/ WEB [] false changeLanguage
31 [GET] /en/*/ WEB [] false changeLanguage
32 [GET] /es/*/ WEB [] false changeLanguage
33 [GET] /example/ WEB [] false Future
34 [GET] /example/cookie/ WEB [] false exampleCookie
35 [POST] /example/cookie/ WEB [] false exampleAddCookie
36 [GET] /example/cookie/ WEB [] false exampleAddCookie
37 [DELETE] /example/database/ WEB [] false exampleDatabase
38 [GET] /example/database/ WEB [] false exampleDatabase
39 [PUT] /example/database/ WEB [] false exampleDatabase
40 [POST] /example/database/ WEB [] false exampleDatabase
41 [GET] /example/dump/ WEB [] false exampleDump
42 [POST] /example/email/ WEB [] false exampleEmailSend
43 [GET] /example/email/ WEB [] false exampleEmail
44 [GET] /example/error/ WEB [] false exampleError
45 [GET] /example/form/ WEB [] false exampleForm
46 [POST] /example/form/ WEB [] false loginPost
47 [OPTIONS] /example/host/ WEB [] false Future
48 [HEAD] /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 [PATCH] /example/host/ WEB [] false Future
54 [PUT] /example/host/ WEB [] false Future
55 [POST] /example/host/ WEB [] false Future
56 [HEAD] /example/host/ WEB [] false Future
57 [DELETE] /example/host/ WEB [] false Future
58 [GET] /example/host/ WEB [] false Future
59 [PATCH] /example/host/ WEB [] false Future
60 [TRACE] /example/host/ WEB [] false Future
61 [CONNECT] /example/host/ WEB [] false Future
62 [GET] /example/host/ WEB [] false Future
63 [POST] /example/host/ WEB [] false Future
64 [PUT] /example/host/ WEB [] false Future
65 [DELETE] /example/host/ WEB [] false Future
66 [INSERT] /example/host/ WEB [] false Future
67 [GET] /example/language/ WEB [] false exampleLanguage
68 [GET] /example/pagination/ WEB [] false paginationExample
69 [GET] /example/panel/ WEB [admin] true exampleAuth
70 [PUT] /example/panel/ WEB [admin] true exampleAuth
71 [HEAD] /example/panel/ WEB [admin] true exampleAuth
72 [DELETE] /example/panel/ WEB [admin] true exampleAuth
73 [INSERT] /example/panel/ WEB [admin] true exampleAuth
74 [CONNECT] /example/panel/ WEB [admin] true exampleAuth
75 [OPTIONS] /example/panel/ WEB [admin] true exampleAuth
76 [TRACE] /example/panel/ WEB [admin] true exampleAuth
77 [PATCH] /example/panel/ WEB [admin] true exampleAuth
78 [POST] /example/panel/ WEB [admin] true exampleAuth
79 [GET] /example/person/ WEB [] false allPerson
80 [POST] /example/person/ WEB [] false addNewPerson
81 [POST] /example/person/replace/{id}/ WEB [] false replacePerson
82 [GET] /example/person/{id}/ WEB [] false onePerson
83 [POST] /example/person/{id}/ WEB [] false updateOrDeletePerson
84 [DELETE] /example/person/{id}/ WEB [] false deletePerson
85 [GET] /example/persons/ WEB [] false allPerson
86 [GET] /example/route/ WEB [] false exampleRoute
87 [GET] /example/socket/ WEB [] false exampleSocket
88 [GET] /fa/*/ WEB [] false changeLanguage
89 [GET] /fa/*/ WEB [] false changeLanguage
90 [GET] /fr/*/ WEB [] false changeLanguage
91 [GET] /info/ WEB [] false info
92 [GET] /it/*/ WEB [] false changeLanguage
93 [GET] /ja/*/ WEB [] false changeLanguage
94 [GET] /ko/*/ WEB [] false changeLanguage
95 [PATCH] /logout/ WEB [] false logout
96 [OPTIONS] /logout/ WEB [] false logout
97 [GET] /logout/ WEB [] false logout
98 [POST] /logout/ WEB [] false logout
99 [PUT] /logout/ WEB [] false logout
100 [HEAD] /logout/ WEB [] false logout
101 [TRACE] /logout/ WEB [] false logout
102 [INSERT] /logout/ WEB [] false logout
103 [CONNECT] /logout/ WEB [] false logout
104 [DELETE] /logout/ WEB [] false logout
105 [GET] /nl/*/ WEB [] false changeLanguage
106 [GET] /ru/*/ WEB [] false changeLanguage
107 [GET] /swagger/ WEB [] false Future
108 [GET] /tr/*/ WEB [] false changeLanguage
109 [PATCH] /ws/ WEB [] false socket
110 [TRACE] /ws/ WEB [] false socket
111 [CONNECT] /ws/ WEB [] false socket
112 [INSERT] /ws/ WEB [] false socket
113 [DELETE] /ws/ WEB [] false socket
114 [HEAD] /ws/ WEB [] false socket
115 [PUT] /ws/ WEB [] false socket
116 [POST] /ws/ WEB [] false socket
117 [GET] /ws/ WEB [] false socket
118 [OPTIONS] /ws/ WEB [] false socket
119 [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,
        )
      ],
    ),
  ];
}