自定义基本路径播放框架 [英] custom base path play framework

查看:74
本文介绍了自定义基本路径播放框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为所有路由配置自定义根基础路径?

Is there a way to configure a custom root base path for all the routes?

例如:

/login
/user
/group

但我想在所有内容之前加上

but I want to prepend everything with:

/v1/login
/v1/user
/v1/group

是否要通过application.conf做到这一点?

anyway to do it via a application.conf?

推荐答案

是.假设您的routes文件具有以下路由

Yes. Suppose your routes file has the following routes

GET /login  controllers.login()
GET /user   controllers.user()
GET /group  controllers.group()

要实现所需的功能,只需将规则重命名或移动到新文件(例如v1.routes),然后在主routes文件中使用

To achieve what you want, you just have to rename or move that rules to a new file (for example v1.routes) and then in the main routes file, use

->      /v1     v1.Routes

v1文件中存在的所有路由现在都以v1

All the routes present in v1 file are now prepended with v1

这篇关于自定义基本路径播放框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆