From bd3d648048548301906b9829766ace518220aad4 Mon Sep 17 00:00:00 2001 From: Guillaume Bort Date: Mon, 11 Apr 2011 14:37:48 +0200 Subject: [PATCH] Fix Router --- framework/src/play/mvc/Http.java | 8 ++++++++ framework/src/play/mvc/Router.java | 4 ++-- .../just-test-cases/app/controllers/Application.java | 8 ++++++++ .../just-test-cases/app/views/Application/index.html | 3 ++- samples-and-tests/just-test-cases/conf/routes | 2 ++ samples-and-tests/just-test-cases/test/routing.test.html | 6 +++--- 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/framework/src/play/mvc/Http.java b/framework/src/play/mvc/Http.java index 4b57576637..4a96dad424 100644 --- a/framework/src/play/mvc/Http.java +++ b/framework/src/play/mvc/Http.java @@ -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). diff --git a/framework/src/play/mvc/Router.java b/framework/src/play/mvc/Router.java index dcffbc8616..a078404222 100644 --- a/framework/src/play/mvc/Router.java +++ b/framework/src/play/mvc/Router.java @@ -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; } diff --git a/samples-and-tests/just-test-cases/app/controllers/Application.java b/samples-and-tests/just-test-cases/app/controllers/Application.java index 8ef44105e3..ca059d47ee 100644 --- a/samples-and-tests/just-test-cases/app/controllers/Application.java +++ b/samples-and-tests/just-test-cases/app/controllers/Application.java @@ -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); diff --git a/samples-and-tests/just-test-cases/app/views/Application/index.html b/samples-and-tests/just-test-cases/app/views/Application/index.html index 7a1e7dd6c3..d6a9d09da3 100644 --- a/samples-and-tests/just-test-cases/app/views/Application/index.html +++ b/samples-and-tests/just-test-cases/app/views/Application/index.html @@ -45,4 +45,5 @@

14: @@{Application.ok('titi')}

15: @@{Application.ok(123)}

16: @@{Application.ok(12345)}

17: @@{Application.ok('A')}

-

18: @@{Application.ok('TITI')}

\ No newline at end of file +

18: @@{Application.ok('TITI')}

+

19: @@{Application.imagesAssets()}

\ No newline at end of file diff --git a/samples-and-tests/just-test-cases/conf/routes b/samples-and-tests/just-test-cases/conf/routes index 60fd7cbfa0..fac6ef84ac 100644 --- a/samples-and-tests/just-test-cases/conf/routes +++ b/samples-and-tests/just-test-cases/conf/routes @@ -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 diff --git a/samples-and-tests/just-test-cases/test/routing.test.html b/samples-and-tests/just-test-cases/test/routing.test.html index 9dc80e2d4f..56a15cd6f0 100644 --- a/samples-and-tests/just-test-cases/test/routing.test.html +++ b/samples-and-tests/just-test-cases/test/routing.test.html @@ -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} \ No newline at end of file