A simple server, support converting yaml to json through http requests.
./yaml2json-server --listen 0.0.0.0 --port 8080 --key 3kf7^21%P9d --sub-path "/convert"
yaml2json-server.exe --listen 0.0.0.0 --port 8080 --key 3kf7^21%P9d --sub-path "/convert"
docker-compose.yml
services:
yaml2json-server:
container_name: "yaml2json-server"
image: "yqs112358/yaml2json-server"
restart: unless-stopped
environment:
Y2JS_LISTEN_ADDR: "0.0.0.0"
Y2JS_LISTEN_PORT: 8080
Y2JS_AUTH_KEY: "3kf7^21%P9d"
Y2JS_URL_SUB_PATH: "/convert"
ports:
- 8080:8080
Convert the YAML plain text in POST request body to JSON.
Make a POST request to https://<YOUR-SERVER-ADDRESS>/convert
with Body:
key1: 1234
key2:
nestedKey: "data"
Response:
{
"key1": 1234,
"key2": {
"nestedKey": "data"
}
}
Read YAML text from the given URL-encoded URL, then convert to JSON.
Make a GET request to
https://<YOUR-SERVER-ADDRESS>/convert?url=https%3A%2F%2Fanother-domain%2Fdir%2Fdata.yaml
Response:
{
"key1": 1234,
"key2": {
"nestedKey": "data"
}
}
Pre-shared auth key set in the configuration to avoid http-api abuse. Use one of the following methods to carry the key with request:
curl https://<YOUR-SERVER-ADDRESS>/convert?key=<YOUR-AUTH-KEY>& ......
AUTH_DATA=$(echo -n ":<YOUR-AUTH-KEY>" | base64)
curl -H "Authorization: Basic $AUTH_DATA" https://<YOUR-SERVER-ADDRESS>/convert ...
Command-line Arg | Environment Var | Default Value | Description |
---|---|---|---|
--listen |
Y2JS_LISTEN_ADDR | "0.0.0.0" | HTTP listen address |
--port |
Y2JS_LISTEN_PORT | 8080 | HTTP listen port |
--key |
Y2JS_AUTH_KEY | "" | HTTP-API auth key |
--sub-path |
Y2JS_URL_SUB_PATH | "/" | HTTP Serve sub-path |
go build -o ./dist -ldflags="-s -w" -trimpath yaml2json-server
y2jLib in bronze1man/yaml2json