Skip to content

Routing

Brian Zou edited this page Mar 6, 2019 · 7 revisions

Router

path definition rules

Basic rule

#
# [GET,POST,PUT...] path controller.method
#

Example:

GET / index.index
GET /users user.list
GET /user/{id} user.detail
GET /user/{id<\d+>} user.detail
  1. The path is unique

The defined path cannot be ambiguous

#The following entry conflicts
* /home index.show
GET /home index.index
  1. Default static path /

The Router automatically adds the following routes according to the situation. By default, the wwwroot directory is used as the static file path.

GET / staticDir: wwwroot
  1. Index file search

If the routing path does not exactly match the Action method on the Controller, go to Search for a static file with the file format path + default static file . The default static file is as follows:

Index.html, index.htm, default.html, default.htm, home.html

Default Profile

Default route config file is:

config/routes

Packet Routing

If you want use advanced method, allow bind domain & directory go to config/application.conf find this option:

route.groups = admin:path:admincp, api:domain:api.example.com

You have create groups config files:

config/admin.routes
config/api.routes
Clone this wiki locally