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

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

问题描述

我们正在将一个接缝应用程序(2个应用程序)移植到一个Play应用程序中以立即测试游戏(嗯,移植更困难的场景...到目前为止,还算不错).

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

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) { ... }

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

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

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