Services tells a story based on a template and input words
- A story action should receive a template and words to be replaced in the template
- Input consists of an array os words and a string template
- The string templates references words via &1 (first word), &2 (second word) and so forth
- The output is a string of the word references replaced with their actual words
- Being a RESTful microservice I thought it would be best to return a JSON object instead of a plain string
- The words array is an optional input
You can test your microservice with omg run
:
$ omg run story -a template='On a fine &2 he saw &1.' -a words='["a sparrow", "morning"]'
✔ Ran action: `story` with output: "On a fine morning he saw a sparrow."```
```$ omg run story -a template='Afterwards he ate &1 & &2.' -a words='["an apple", "two bananas"]'
✔ Ran action: `story` with output: "Afterwards he ate an apple & two bananas."```
```$ omg run story -a template='No words.'
✔ Ran action: `story` with output: "No words."```