Add methods for externalizing links to SlingHttpServletRequest
--------------------------------------------------------------

                 Key: SLING-1629
                 URL: https://issues.apache.org/jira/browse/SLING-1629
             Project: Sling
          Issue Type: New Feature
          Components: API, Engine
            Reporter: Alexander Klimetschek
            Priority: Minor


When creating links in responses there are two cases:

1) create it for use by the browser: URLs relative to the current request
2) link used by external apps: absolute URL including hostname etc.

For 1), you can already use ResourceResolver.map(request, path) (important to 
use the request-based here).

For 2), when you explicitly want absolute URLs (eg. for rss feeds, links in 
emails, etc.), the ResourceResolver map methods will only add a host/port if 
such a configuration is part of /etc/map. There is no default to use the 
host/port from the current request.

In order to provide convenient short access to those features, an externalize 
method on the sling request object is better for both cases:

case 1) relative url

    slingRequest.externalize("/my/path")

same as slingRequest.getResourceResolver().map(slingRequest, "/my/path"))

case 2) absolute url

    slingRequest.externalize("http", "/my/path")

produces e.g. http://localhost:8080/my/path

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to