Skip to content

Commit

Permalink
Fix Router
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumebort committed Apr 11, 2011
1 parent 8078b9a commit bd3d648
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
8 changes: 8 additions & 0 deletions framework/src/play/mvc/Http.java
Expand Up @@ -441,6 +441,14 @@ public static Request current() {
return current.get();
}

/**
* Useful because we sometime use a lazy request loader
* @return itself
*/
public Request get() {
return this;
}

/**
* This request was sent by an Ajax framework.
* (rely on the X-Requested-With header).
Expand Down
4 changes: 2 additions & 2 deletions framework/src/play/mvc/Router.java
Expand Up @@ -579,8 +579,8 @@ public String toString() {

public void absolute() {
String hostPart = host;
String domain = Http.Request.current().domain;
int port = Http.Request.current().port;
String domain = Http.Request.current().get().domain;
int port = Http.Request.current().get().port;
if (port != 80 && port != 443) {
hostPart += ":" + port;
}
Expand Down
Expand Up @@ -90,6 +90,14 @@ public static void index2() {
public static void simpleStatusCode() {
response.status = 204;
}

public static void imagesAssets() {

}

public static void dashboard(String client) {

}

public static void hello(String name) {
render(name);
Expand Down
Expand Up @@ -45,4 +45,5 @@ <h2>14: @@{Application.ok('titi')}</h2>
<h2>15: @@{Application.ok(123)}</h2>
<h2>16: @@{Application.ok(12345)}</h2>
<h2>17: @@{Application.ok('A')}</h2>
<h2>18: @@{Application.ok('TITI')}</h2>
<h2>18: @@{Application.ok('TITI')}</h2>
<h2>19: @@{Application.imagesAssets()}</h2>
2 changes: 2 additions & 0 deletions samples-and-tests/just-test-cases/conf/routes
Expand Up @@ -17,6 +17,8 @@ GET /{lucky}/doIt Application.showIt

GET www.zenexity.com/hello Application.helloZen
GET {clientName}.myApp.com/home Application.myHomePage
GET assets.{_}/images Application.imagesAssets
GET {client}.{_}/dashboard Application.dashboard

POST /ressource/file/{id} Rest.postOrPutFile
PUT /ressource/file/{id} Rest.postOrPutFile
Expand Down
6 changes: 3 additions & 3 deletions samples-and-tests/just-test-cases/test/routing.test.html
Expand Up @@ -129,16 +129,16 @@
assertTextPresent('5: http://localhost:9003/public/image.gif')
assertTextPresent('6: /public/image.gif')
assertTextPresent('7: /hello')
assertTextPresent('8: http://www.zenexity.com/hello')
assertTextPresent('8: http://www.zenexity.com:9003/hello')
assertTextPresent('9: /')
assertTextPresent('10: http://localhost:9003/')
assertTextPresent('11: /home')
assertTextPresent('12: http://bob.myApp.com/home')
assertTextPresent('12: http://bob.myApp.com:9003/home')
assertTextPresent('13: http://localhost:9003/strike/doIt')
assertTextPresent('14: http://localhost:9003/re/titi')
assertTextPresent('15: http://localhost:9003/application/ok?re=123')
assertTextPresent('16: http://localhost:9003/re/12345')
assertTextPresent('17: http://localhost:9003/application/ok?re=A')
assertTextPresent('18: http://localhost:9003/re/TITI')

assertTextPresent('19: http://assets.localhost:9003/images')
#{/selenium}

0 comments on commit bd3d648

Please sign in to comment.