Skip to content
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

Add template functions #218

Merged
merged 2 commits into from Aug 24, 2020
Merged

Add template functions #218

merged 2 commits into from Aug 24, 2020

Conversation

bojand
Copy link
Owner

@bojand bojand commented Aug 24, 2020

Adds template functions:

newUUID - Generates a new UUID for each invocation.

randomString - Generates a new random string for each incovation. Accepts a length parameter. If the argument is <= 0 then a ranom string is generated with a random length between length of 2 and 16.

Example usage with data:

-d '{"order_id":"{{newUUID}}", "item_id":"{{newUUID}}", "sku":"{{randomString 8 }}", "product_name":"{{ranomdString 0}}"}'

Would result in data with JSON representation:

{
  "order_id": "3974e7b3-5946-4df5-bed3-8c3dc9a0be19",
  "item_id": "cd9c2604-cd9b-43a8-9cbb-d1ad26ca93a4",
  "sku": "HlFTAxcm",
  "product_name": "xg3NEC"
}

Also adds WithTemplateFuncs() API option.

Addresses #213.

@bojand bojand merged commit 062100d into master Aug 24, 2020
@bojand bojand deleted the template_funcs branch August 24, 2020 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant