Mention internal requests + tentative fluent API
1 file changed
tree: 8221174c59e8247f8ea8c4fe5fb0a88e7363abd1
  1. src/
  2. .gitignore
  3. CODE_OF_CONDUCT.md
  4. CONTRIBUTING.md
  5. Jenkinsfile
  6. LICENSE
  7. pom.xml
  8. README.md
README.md

Build Status Test Status Maven Central JavaDocs License

Apache Sling Servlet Helpers

This module is part of the Apache Sling project.

It provides mock implementations of the SlingHttpServletRequest, SlingHttpServletRepsonse and related classes.

These helpers can be used for testing, like the Sling Mocks do.

They are also useful for internal requests using the SlingRequestProcessor service, like in the GraphQL Core module which uses that technique to retrieve GraphQL schemas using the powerful Sling request processing mechanisms.

How about a fluent API?

Internal requests using the SlingRequestProcessor service currently require a lot of boilerplate code, which we could remove by creating a fluent interface that manages the required request and response objects under the hood.

Maybe something like:

InternalRequest
  .get(SlingRequestProcessor, ResourceResolver)
  .forPath("/yocats")
  .withSelectors("farenheit", "451")
  .withExtension("json")
  .execute()
  .checkStatus(200)
  .checkContentType("application/json")
  .getContentAsStream();

This is just an idea so far...patches welcome, and maybe such an API doesn't belong in this module, but would just use its helpers.