diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2017-11-27 22:16:38 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-27 22:16:38 -0500 |
| commit | 99b900dbde35ceea30ec9479bf636e291fae72c9 (patch) | |
| tree | 7f59be8f7fc2b16f834139a179d8251048615a39 /docs | |
| parent | e5d193a05b2c4515ce2da0fcb59ad8668dec3977 (diff) | |
| parent | 2766d2ec1ed1433d315031f40d6733858e69eed0 (diff) | |
Merge pull request #234 from hairyhenderson/support-type-setting-with-url-query
Support setting MIME type with URL query string
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/content/functions/data.md | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/docs/content/functions/data.md b/docs/content/functions/data.md index 0243b25b..dbbf45f2 100644 --- a/docs/content/functions/data.md +++ b/docs/content/functions/data.md @@ -11,7 +11,7 @@ A collection of functions that retrieve, parse, and convert structured data. Parses a given datasource (provided by the [`--datasource/-d`](#--datasource-d) argument). -Currently, `file://`, `stdin://`, `http://`, `https://`, and `vault://` URLs are supported. +Currently, `file://`, `stdin://`, `http://`, `https://`, `vault://`, and `boltdb://` URLs are supported. Currently-supported formats are JSON, YAML, TOML, and CSV. @@ -53,6 +53,22 @@ $ echo 'foo' | gomplate -i '{{ include "data" }}' -d data=stdin: foo ``` +### Overriding the MIME type + +On occasion it's necessary to override the MIME type a datasource is parsed with. +To accomplish this, gomplate supports a `type` query string parameter on +datasource URLs. This can contain the same value as a standard +[HTTP Content-Type](https://tools.ietf.org/html/rfc7231#section-3.1.1.1) +header. + +For example, to force a file named `data.txt` to be parsed as a JSON document: + +```console +$ echo '{"foo": "bar"}' > /tmp/data.txt +$ gomplate -d data=file:///tmp/data.txt?type=application/json -i '{{ (ds "data").foo }}' +bar +``` + ### Usage with HTTP data ```console |
