Hi,
On Wed, Jun 3, 2020 at 11:03 AM Bertrand Delacretaz
<[email protected]> wrote:
> ...for my use cases a fluent interface to the SlingRequestProcessor would be
> nice...
I have now implemented a fluent helper for internal requests, using
either the SlingRequestProcessor (for full fidelity compared to HTTP
requests) or the ServletResolver (faster, no Servlet Filters - thanks
Radu for mentioning that option), at SLING-9512 and [1].
Here's a usage example, the tests [1] have more:
OutputStream os = InternalRequest
.servletRequest(resourceResolver, servletResolver, "/some/path")
.withResourceType("website/article/news")
.withResourceSuperType("website/article")
.withSelectors("print", "a4")
.withExtension("pdf")
.execute()
.checkStatus(200)
.checkResponseContentType("application/pdf")
.getResponse()
.getOutputStream();
Feedback is welcome! I'm using this in the GraphQL core that I'd like
to release soon, will need to release the servlet-helpers module as
well.
-Bertrand
[1] https://github.com/apache/sling-org-apache-sling-servlet-helpers