This is an automated email from the ASF dual-hosted git repository.
bdelacretaz pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlet-helpers.git
The following commit(s) were added to refs/heads/master by this push:
new c3e4ad8 Mention internal requests + tentative fluent API
c3e4ad8 is described below
commit c3e4ad89f5af8ed312a8451e9c992047a79668b7
Author: Bertrand Delacretaz <[email protected]>
AuthorDate: Wed Jun 3 11:12:58 2020 +0200
Mention internal requests + tentative fluent API
---
README.md | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index f82a559..4694e4e 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,31 @@
This module is part of the [Apache Sling](https://sling.apache.org) project.
-Mock implementations of SlingHttpServletRequest, SlingHttpServletRepsonse and
related classes.
+It provides mock implementations of the `SlingHttpServletRequest`,
`SlingHttpServletRepsonse` and related classes.
-These are used by sling-mock, but can be used standalone and deployed to an
OSGi container as well.
+These helpers can be used for **testing**, like the [Sling
Mocks](https://sling.apache.org/documentation/development/sling-mock.html) do.
+
+They are also useful for **internal requests using the `SlingRequestProcessor`
service**, like in the
+[GraphQL Core](https://github.com/apache/sling-org-apache-sling-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.