Support using filters to construct request body
Problem to solve
I'm testing AWS endpoints (actually AWS Lambda functions), which sometimes desire JSON requests with an embedded base64 payload. Just writing out the request this way means that the .hurl file has some JSON with a big base64 blob in the middle, which isn't particularly easy to read.
Proposal
Since there's already filter support for base64Encode, it'd be great if I could use variable support in [Options] to encode my base64 and then embed it in the JSON as a template:
[Options]
variable: base64_data="test" base64Encode
```json
{
"records": [
{
"message": {{base64_data}}
}
]
}
```
to produce a request body of
{"records":[{"message":"dGVzdA=="}]}
Additional context and resources
Tasks to complete
- [ ] ...
Ah I think this will be the generators feature mentioned by @jcamiel in https://github.com/Orange-OpenSource/hurl/issues/2258#issuecomment-1861512751.
Yes, we plan to be use more complex expression in template, variable etc like:
POST https://foo.com
{
"records": [
{
"message": {{ my_var base64Encode }}
}
]
}
Generators (we call it function now) are part of these evolutions and allow to produce data like date or uuid:
POST https://foo.com
{
"records": [
{
"message": {{ newUuid }}
}
]
}
And we'll be able to combine functions with filters:
POST https://foo.com
{
"records": [
{
"message": {{ newUuid base64UrlDecode }}
}
]
}
I'm not sure of the roadmap but this is the plan we're committing on.