You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Going from Play1 to RePlay we found Router.getFullUrl was deprecated in favor of a method with the same name, but takes a Http.Request as argument. I think I get the reason for this change: the old Router.getFullUrl took some request data from thread local, and that's dangerous way to get an implicit dependency on the Http.Request.
In several cases we build full urls in our app without a request context: in the model code (not often, but sometimes we need to put a link somewhere) and in our background workers.
Since Router.getFullUrl only needs the base url (with getBaseUrl) from Http.Request, I think it is better to create another, overloaded, method in Router:
This method does not require the whole of a Request (that sometimes is not even available) and
Possibly deprecating the getFullUrl that takes Http.Request as an argument as well, as passing the whole request is a bit much when all we need it the baseUrl.
When doing this I suggest we do so for some other methods in Router that expect a Http.Request argument, namely:
Router.actionToUrl(String action, Map<String, Object> actionArgs, Http.Request request, Http.Response response) -- the response is only used for the character encoding, so a new overloaded method of could be created with the the reponse argument replaced with a @Nullable Charset encoding for which Play.defaultWebEncoding is picked with null was given.
Router.reverse(String action, Map<String, Object> args, Http.Request request, Http.Response response) -- same comment as the previous item
@cies I totally agree with all suggested changes. Yes, Request parameter was needed there only to get baseUrl. And yes, we could provide baseUrl as a parameter.
Going from Play1 to RePlay we found
Router.getFullUrl
was deprecated in favor of a method with the same name, but takes aHttp.Request
as argument. I think I get the reason for this change: the oldRouter.getFullUrl
took some request data from thread local, and that's dangerous way to get an implicit dependency on theHttp.Request
.In several cases we build full urls in our app without a request context: in the model code (not often, but sometimes we need to put a link somewhere) and in our background workers.
Since
Router.getFullUrl
only needs the base url (withgetBaseUrl
) fromHttp.Request
, I think it is better to create another, overloaded, method inRouter
:This method does not require the whole of a Request (that sometimes is not even available) and
Possibly deprecating the
getFullUrl
that takesHttp.Request
as an argument as well, as passing the whole request is a bit much when all we need it the baseUrl.When doing this I suggest we do so for some other methods in
Router
that expect aHttp.Request
argument, namely:Router.actionToUrl(String action, Map<String, Object> actionArgs, Http.Request request, Http.Response response)
-- the response is only used for the character encoding, so a new overloaded method of could be created with the the reponse argument replaced with a@Nullable Charset encoding
for whichPlay.defaultWebEncoding
is picked withnull
was given.Router.reverse(String action, Map<String, Object> args, Http.Request request, Http.Response response)
-- same comment as the previous itemRouter.getFullUrl(String action, Map<String, Object> args, Http.Request request)
Router.getBaseUrl(Http.Request request)
Router.getFullUrl(String action, Http.Request request)
Router.reverse(String action, Map<String, Object> args, Http.Request request, Http.Response response)
But not these (only used internally by the framework):
Router.routeOnlyStatic(Http.Request request)
Router.route(Http.Request request)
Router.processRoute(Http.Request request, MatchingRoute match)
I gladly make a PR implementing the above, but first I'd like to know if we all agree this is a good way fwd.
The text was updated successfully, but these errors were encountered: