[ https://issues.apache.org/jira/browse/SLING-1629?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alexander Klimetschek resolved SLING-1629. ------------------------------------------ Resolution: Won't Fix As per discussion on http://sling.markmail.org/thread/tdqkqnianlp4xbgp I revert this feature request: - no agreement - methods too specific (yet) for "polluting" on a first-class interface - for background service cases, a method creating absolute URLs (instead of relative such as the map() methods) on the ResourceResolver would make more sense - I have a custom service that does all I need atm > 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 > Attachments: SLING-1629.patch > > > 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. > Also, if a hostname is configured and you use map(request, path), because > that is required for adding the context path, it will _strip_ it from the map > call if the current request goes to that hostname, which is probably the > normal case. The map(request, path) call is clearly aimed at relative URLs, > case 1). > 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.