Reputation: 746
In CQ, if I request a resource such as localhost:4502/content/geometrixx/en.json
, I would get the node information in JSON format. The same applies for the XML extension as well.
My question is, where is it implemented that the node information is rendered in JSON format if the URL extension is json
?
Basically, the extension is just simply text and another part of the URL structure. Simply appending json
won't magically fetch the information in JSON format.
Obviously, one would have to use this information to write logic for returning the node information in JSON.
I'm trying to learn about the internal workings of CQ. Maybe the concept of getting JSON is the same in Apache Sling as well? I don't know if it's CQ specific or not, but the point is same. I've tried /system/console/jcrresolver
as well, but it didn't help.
Upvotes: 3
Views: 2739
Reputation: 1921
This is a function of Apache Sling. The DefaultGetServlet is invoked on all GET requests. The servlet checks the request's extension and uses the corresponding renderer if it's enabled.
Look through the code of the DefaultGetServlet and as well as the renderers in this directory such as the HTML renderer, JSON renderer and XML renderer.
The documentation is located here: https://sling.apache.org/documentation/bundles/rendering-content-default-get-servlets.html
Upvotes: 6