-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't seem to use the "req" object in moco groovy scripts #34
Comments
To be clarified. Thanks for reporting. I am on vacation now so investigation will take a little bit more time |
No worries! There is a workaround by making a rule per id hardcoded, but it would be cleaner if that wasnt needed ! |
If you know how to fix it don't hesitate to create a PR 😁 |
I had a look, and it is harder than I thought it would be. I think we would have to make a new ContentResourceReader in moco, like the following ones: We could make a JcrResourceReader, that can then be used in the template resource reader to find the correct location in jcr, instead of having the repository.readText, which can't be used in the template logic. You could then do
After further investigation I also found that the req object is available, but because we are using groovy, if you use $ it is already interpreted by groovy, so you would have to type
|
FYI I already have requested these problems somehow on Moco side, but I am afraid no simplifications are done till now. @royteeuwen about '$' ... or simply wrap your string into ' not " :) you wrote:
consider:
about file content readers... if you have sth working, I mean code changes, don't hesitate to share it via PR. Even if it will be not completed, could be a base for further changes, when I will have some time I could complete them or sb else |
I have started with a branch ;) master...royteeuwen:feature/add-jcr-resource-reader It already comes into the correct classes, you can do response(jcr('/content/my-file.json')) but still have work to of course read the actual resource :D |
Cool 👍 |
#36 added an initial implementation that works |
Yep. I was trying sth similar to what you did. The moco API looks nice but actually it is tricky and not straightforward. |
Thanks @royteeuwen, I am closing as it is merged to master. I added integration test for this functionality |
I'm trying to use an example of the api docs of moco:
But I get following response:
What I actually want to achieve is the following:
The text was updated successfully, but these errors were encountered: