Routing

Heromyth edited this page Jun 1, 2018 · 6 revisions

Router

路径定义规则

  1. 基本规则
#
# [GET,POST,PUT...]    path    controller.method
#

举例:

GET    /                 index.index
GET    /users            user.list
GET    /user/{id}        user.detail
GET    /user/{id<\d+>}   user.detail
  1. 路径唯一

定义的路径不能有二义性

# 以下条目存在冲突
*		/home						index.show
GET		/home						index.index
  1. 默认静态路径/

Router会根据情况自动添加以下路由,默认将wwwroot目录做为静态文件路径。

GET		/						staticDir:wwwroot
  1. Index文件搜索

如果路由路径未完全匹配上Controller上的Action方法,则转去搜索静态文件,文件格式为路径+默认静态文件。默认静态文件如下:

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

默认配置文件

default route config file is:

config/routes

分组路由

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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.