So I can get a clear picture of the request, a typical request would be
for?

/host/whitepaper.pdf/host/true/version-1/host/-/users/john123


-- 
Jason

On Fri, Mar 6, 2015, at 09:50 AM, Duy Nguyen wrote:
>  Hello,
> 
> I'm bringing here a use case in Sling and look forward to receiving some
> opinions from the community.
> 
> I need to write a server-side app that serves customized RESTful APIs for
> a
> client app (which is stable and the set of APIs is fixed). The problem
> comes from "ugly" API urls that can hardly be mapped into the resource
> model of Sling, for example:
> 
> */myhost/{documentName}/myhost/{**documentName*
> *}/{hasRevision}/{revisionID}/myhost/-/users/{userName}*
> 
> Especially properties like “documentName", “revisionID" and "userName"
> are
> not necessarily stored in jcr resources, but can also be from external
> sources. The flag “hasRevision” is either true or false value, to check
> if
> the document has revision to be returned. So there must be some
> middleware
> that handles the requests coming to each of those paths (to determine if
> the needed resource can be retrieved from jcr or external sources, and
> revision to be taken into account).
> 
> Thinking in the implementation of some regular web frameworks (Django,
> Sinatra, etc.), it can be done by route mapping, such as:
> *get("/myhost/:**documentName*
> */:hasRevision?/:revisionID?") function()
> {…}get("/myhost/-/users/:userName") function() {…}*
> 
> Initially I have come up with two solutions in Sling:
> 
> 1- Write a "global SlingServlet" for "/myhost/", and then the rest of the
> url are params that will be analyzed in the servlet to handle different
> request patterns. However I don't think this is a very elegant solution,
> because this only one servlet is responsible for all requests following
> the
> path.
> 
> 2- Use Sling Resource Mappings
> <http://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html>
> to
> redirect the requests (categorized by reg-ex) to different resources, and
> then write separate SlingServlet for each of those resources. I still
> have
> some doubt if this is feasible.
> 
> Do you have some suggestions?
> 
> Thanks,
> Duy

Reply via email to