The HelloScript example is a simple example which will print a message to the log whenever any resource is read in this application.
-
How to setup the preRead and postRead javascript functions
-
How to retrieve the path from the request and response objects
The target specified in the metadata.json file is set for every access under the /helloscript url.
"target-path" : "/helloscript/**"
Since the example's target path is for everything under the /helloscript url, you can run the example by accessing anything under this context and watching the logs for the message output.
Possible urls include:
function preRead(request, libraries) {
print("Hello incoming request for " + request.path);
}
function postRead(response, libraries) {
print("Goodbye outgoing response for " + response.request.path);
}