Play! framework: what is the difference between Router.getFullUrl ("action") and Router.reverse ("action"). absolute ()?

I need an absolute URL in my Play! 1.2.4 as a callback for OAuth authentication (using Scribe .

My application works behind the Apache virtual proxy server to be accessible through a URL with a subdomain, for example, "http://myapp.mydomain.com", proxying "http://127.0.0.1:9000". ProxyPreserveHostset to On. In my game! application, I have the following property: application.baseUrl=http://myapp.mydomain.com/.

To calculate this absolute URL, I used a piece of code, for example:

Router.ActionDefinition ad = Router.reverse("Controller.callback");
ad.absolute();
return ad.url;

This code worked great with Play! 1.2.3: he returned "http://myapp.mydomain.com/callback".

Now that I am using Play! 1.2.4, this code now returns "http://www.mydomain.com:9000/callback" (the translated URL is a virtual proxy without a subdomain), as if Play! now using the http request url to create this absolute url.

I empirically replaced this code with Router.getFullUrl("Controller.callback"), which fixed my problem.

Router.getFullUrl() Router.absolute() (booo!), , . , Router.absolute() HTTP- URL-, Router.getFullUrl() application.baseUrl. Apache ( !), ProxyPreserveHost, On, , Play! , , Play! 1.2.3 1.2.4.

.

+5
1

, (, github). , Play! :), javadocs!

, ... !, :

, , - : @@{…}. URL- , . ?

Router.reverse("action", true)?

, URL- "localhost: 9000" "" ?

1.2.4:

String getFullUrl(...) getBaseUrl() + actionDefinition=reverse(...)

String getBaseUrl() application.baseUrl - Http.Request.current().getBase().

ActionDefinition.absolute reverse.

1.2.3 :

reverse

absolute

@@ :

private String __reverseWithCheck(String action, boolean absolute) {
    return Router.reverseWithCheck(action, Play.getVirtualFile(action), absolute);
}

, (, absolute = true), , ActionDefinition

, - ... :) , . URL...

+4

All Articles