UNPKG

971 BMarkdownView Raw
1
2API
3===
4
5Instead of/in addition to using Shunter as a proxy you can also send JSON in the body of an HTTP POST request to the `/template` endpoint and get back a response containing the rendered HTML.
6
7If our app had a template `hello.dust` containing:
8
9```html
10<h1>{data.message}</h1>
11```
12
13Then a POST request like this:
14
15```
16curl -H 'Content-type: application/json' -X POST -d '{"data": {"message": "Hello!"}}' http://your-shunter-server/template/hello
17```
18
19would return:
20
21```html
22<h1>Hello!</h1>
23```
24
25The template to render can also be specified as part of the JSON payload, so the following request would return the same result:
26
27
28```
29curl -H 'Content-type: application/json' -X POST -d '{"layout": {"template": "hello"}, "data": {"message": "Hello!"}}' http://your-shunter-server/template
30```
31
32The maximum size of the POST request can be controlled by setting the `max-post-size` option when starting your app.
33
34
35---
36
37Related:
38
39- [Full API Documentation](index.md)