playframework,您可以在主机名/子域上路由吗? [英] playframework, can you route on hostname/subdomains?

查看:18
本文介绍了playframework,您可以在主机名/子域上路由吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在将一个 Seam 应用程序(2 个应用程序)移植到一个游戏应用程序以测试游戏现在(嗯,移植更难的场景......到目前为止,很好).

We are porting a seam app(2 apps) to one play app to test out play right now(well, porting harder scenarios...so far, so good).

我们希望能够在主机名上路由到根/目录.为了http://alvazan.com/ 我们想路由到我们的 home.html 页面,但对于

We would like to be able to route on hostname though for the root / directory. For http://alvazan.com/ we want to route to our home.html page but for

http://*.premonitionx.com/我们想要路由到仪表板(如果未登录,则重定向到登录页面).

http://*.premonitionx.com/ we want to route to the dashboard(which redirects to login page if not logged in).

最后,我们要路由http://premonitionx.com/ 重定向到 alvazan.com 网页.

Lastly, we want to route http://premonitionx.com/ to redirect to alvazan.com web page.

另外,我们会喜欢像

http://{company}.premonitionx.com/{project}/{release}

http://{company}.premonitionx.com/{project}/{release}

这在游戏框架中甚至可能吗????在开发模式下,我们现在有这些 url 以供无缝开发使用

Is that even possible in the playframework???? In dev mode, we have these urls right now for developing in seam to use

http://{company}.dev.premonitionx.com 这样我们就可以在我们的本地机器上测试并测试不同的公司等等(如您所知,许多测试如果总是本地主机)

http://{company}.dev.premonitionx.com such that we can test on our local machine and test out different companies, etc. etc. (as you know many tests can't be tested if it is always localhost)

谢谢,院长

推荐答案

有些文档比较难找.我在任何真正的文档中都找不到它,但我记得它是发布的一部分...

Some of the docs are more difficult to find for play. I couldn't find this in any of the real documentation but remembered it being part of a release...

http://www.playframework.org/documentation/1.1/releasenotes-1.1#routeHost

路由中的虚拟主机

路由文件现在支持主机匹配.如果必须从主机参数中提取操作参数,这会很有用.例如,对于 SAAS 应用程序,您可以使用:

The routes file now supports Host matching. this can be useful if action parameters must be extracted from the host parameter. For example, for a SAAS application, you could use:

GET    {client}.mysoftware.com/         Application.index

然后像任何其他请求参数一样自动检索客户端值:

and then automatically retrieve the client value as for any other request parameter:

public static void index(String client) {
    // ...
}

这篇关于playframework,您可以在主机名/子域上路由吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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