API quick-start
- Basic terminal / command line skills
- and
curl
in your PATH
First start Caddy:
Caddy is currently running idle (with a blank configuration). Give it a simple config with curl
:
curl localhost:2019/load \
-X POST \
-H "Content-Type: application/json" \
-d @- << EOF
{
"apps": {
"http": {
"listen": [":2015"],
"routes": [
{
"handle": [{
"handler": "static_response",
"body": "Hello, world!"
}]
}
]
}
}
}
EOF
Now load localhost:2015 in your browser or use curl
:
curl localhost:2015
Hello, world!
We can also define multiple sites on different interfaces with this JSON:
Try out your new “goodbye” endpoint or with curl
to make sure it works:
curl localhost:2016
When you are done with Caddy, make sure to stop it: