Add scripting framework to post-process request
Opened this issue · 2 comments
visola commented
User story
As a user, I want to execute some Javascript after a request to process the results.
Description
A very useful feature from Postman is the ability to execute a script after a request is executed to check the results or extract data from it. Read more here.
To make this work, it's required to add a javascript engine, possibly embed V8 or use an existing API bindings like go-v8.
Acceptance Criteria
- Add Javascript engine
- On the CLI, add a
--post-process
option that receives a file that will be used to post-process the executed request - From profiles, have two ways to execute post process scripts:
- add
requests.postProcessFile
loads a file to be executed - add
requests.postProcessScript
that can be used to inline javascript inside the YAML
- add
- Post process scripts can access the following:
- From the response:
- status code
- body as string
- headers
- From the Request
- URL
- body
- headers
- From the response:
- Post process scripts needs to have the ability to:
- set a session variable
- set a global variable
[ ] set a cookie on the current session- add a new request to be executed, pushing one of the following to the requests queue:
- by request name, loaded from the active profiles
- by creating a request object, following the same structure as in the profile YAML