~ A webservice to render HTML templates from API data ~
Developed by @veeso
Current version: 0.1.2 (25/07/2023)
tokyo-draft is a Rust web service which renders HTML templates starting from incoming data from API. The API allows you to render any template you've pre-configured in the service configuration. The rendered template is then sent via a POST request to a configurable hook.
First configure the environment file as you wish, then source .env and run tokyo-draft with
./tokyo-draft.sh start /var/run/tokyo-draft.pid
At this point tokyo-draft will be served on the specified port in the .env
(or .env.override
) file. (Default: 3011
)
Check web service status:
GET /check
Response:
{
"status": "ok"
}
Render a template with provided data:
POST /render
payload:
{
"template": "my-template",
"data": {
"key1": "value",
"key2": 123,
},
"hookMetadata": {
/* custom data to be passed to hook */
}
}
Response (HTML):
(rendered template)
- In case of missing keys or unknown template returns 400.
It is possible to configure in the environment the key RENDER_HOOK
to an URL which will receive the rendered template as parameter as follows:
{
"body": "RENDERED TEMPLATE HTML SYNTAX BASE64 ENCODED",
"metadata": {
/* data passed as hookMetadata to /render */
}
}
If you like tokyo-draft and you're grateful for the work I've done, please consider a little donation 🥳
You can make a donation with one of these platforms:
Contributions, bug reports, new features and questions are welcome! 😉 If you have any question or concern, or you want to suggest a new feature, or you want just want to improve pavao, feel free to open an issue or a PR.
Please follow our contributing guidelines
View tokyo-draft's changelog HERE
tokyo-draft is licensed under the MIT license.
You can read the entire license HERE