mirror of
https://github.com/caddyserver/website.git
synced 2025-05-06 11:47:12 -04:00
docs: Remove -X POST
Curl automatically uses POST for -d and --data-binary. I intentionally left it in to be explicit to learners, but maybe best practices are better.
This commit is contained in:
parent
0b5062a6ad
commit
03f02e7dfc
6 changed files with 4 additions and 14 deletions
|
@ -68,7 +68,6 @@ Save this to a JSON file:
|
||||||
Then upload it:
|
Then upload it:
|
||||||
|
|
||||||
<pre><code class="cmd bash">curl localhost:2019/load \
|
<pre><code class="cmd bash">curl localhost:2019/load \
|
||||||
-X POST \
|
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d @caddy.json
|
-d @caddy.json
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
@ -104,7 +103,6 @@ Let's change our welcome message from "Hello world!" to something a little more
|
||||||
Save the config file, then update Caddy's active configuration by running the same POST request again:
|
Save the config file, then update Caddy's active configuration by running the same POST request again:
|
||||||
|
|
||||||
<pre><code class="cmd bash">curl localhost:2019/load \
|
<pre><code class="cmd bash">curl localhost:2019/load \
|
||||||
-X POST \
|
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d @caddy.json
|
-d @caddy.json
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
@ -130,7 +128,6 @@ Using the request URI's path, we can traverse into the config structure and upda
|
||||||
|
|
||||||
<pre><code class="cmd bash">curl \
|
<pre><code class="cmd bash">curl \
|
||||||
localhost:2019/config/apps/http/servers/example/routes/0/handle/0/body \
|
localhost:2019/config/apps/http/servers/example/routes/0/handle/0/body \
|
||||||
-X POST \
|
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '"Work smarter, not harder."'
|
-d '"Work smarter, not harder."'
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
@ -171,7 +168,6 @@ We can give our handler object an [`@id` tag](/docs/api#using-id-in-json) to mak
|
||||||
|
|
||||||
<pre><code class="cmd bash">curl \
|
<pre><code class="cmd bash">curl \
|
||||||
localhost:2019/config/apps/http/servers/example/routes/0/handle/0/@id \
|
localhost:2019/config/apps/http/servers/example/routes/0/handle/0/@id \
|
||||||
-X POST \
|
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '"msg"'
|
-d '"msg"'
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
@ -198,7 +194,6 @@ And now we can change the message with a shorter path:
|
||||||
|
|
||||||
<pre><code class="cmd bash">curl \
|
<pre><code class="cmd bash">curl \
|
||||||
localhost:2019/id/msg/body \
|
localhost:2019/id/msg/body \
|
||||||
-X POST \
|
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '"Some shortcuts are good."'
|
-d '"Some shortcuts are good."'
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
|
@ -64,13 +64,13 @@ If the new config is the same as the current one, no reload will occur. To force
|
||||||
|
|
||||||
Set a new active configuration:
|
Set a new active configuration:
|
||||||
|
|
||||||
<pre><code class="cmd bash">curl -X POST "http://localhost:2019/load" \
|
<pre><code class="cmd bash">curl "http://localhost:2019/load" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d @caddy.json</code></pre>
|
-d @caddy.json</code></pre>
|
||||||
|
|
||||||
Note: curl's `-d` flag removes newlines, so if your config format is sensitive to line breaks (e.g. the Caddyfile), use `--data-binary` instead:
|
Note: curl's `-d` flag removes newlines, so if your config format is sensitive to line breaks (e.g. the Caddyfile), use `--data-binary` instead:
|
||||||
|
|
||||||
<pre><code class="cmd bash">curl -X POST "http://localhost:2019/load" \
|
<pre><code class="cmd bash">curl "http://localhost:2019/load" \
|
||||||
-H "Content-Type: text/caddyfile" \
|
-H "Content-Type: text/caddyfile" \
|
||||||
--data-binary @Caddyfile</code></pre>
|
--data-binary @Caddyfile</code></pre>
|
||||||
|
|
||||||
|
@ -152,14 +152,14 @@ baseSlice = append(baseSlice, newElems...)
|
||||||
|
|
||||||
Add a listener address:
|
Add a listener address:
|
||||||
|
|
||||||
<pre><code class="cmd bash">curl -X POST \
|
<pre><code class="cmd bash">curl \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '":8080"' \
|
-d '":8080"' \
|
||||||
"http://localhost:2019/config/apps/http/servers/myserver/listen"</code></pre>
|
"http://localhost:2019/config/apps/http/servers/myserver/listen"</code></pre>
|
||||||
|
|
||||||
Add multiple listener addresses:
|
Add multiple listener addresses:
|
||||||
|
|
||||||
<pre><code class="cmd bash">curl -X POST \
|
<pre><code class="cmd bash">curl \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '[":8080", ":5133"]' \
|
-d '[":8080", ":5133"]' \
|
||||||
"http://localhost:2019/config/apps/http/servers/myserver/listen/..."</code></pre>
|
"http://localhost:2019/config/apps/http/servers/myserver/listen/..."</code></pre>
|
||||||
|
|
|
@ -32,7 +32,6 @@ You can use a config adapter by specifying it on the command line by using the `
|
||||||
Or via the API at the [`/load` endpoint](/docs/api#post-load):
|
Or via the API at the [`/load` endpoint](/docs/api#post-load):
|
||||||
|
|
||||||
<pre><code class="cmd bash">curl localhost:2019/load \
|
<pre><code class="cmd bash">curl localhost:2019/load \
|
||||||
-X POST \
|
|
||||||
-H "Content-Type: application/yaml" \
|
-H "Content-Type: application/yaml" \
|
||||||
--data-binary @caddy.yaml</code></pre>
|
--data-binary @caddy.yaml</code></pre>
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,6 @@ Save this to a JSON file (e.g. `caddy.json`):
|
||||||
Then upload it:
|
Then upload it:
|
||||||
|
|
||||||
<pre><code class="cmd bash">curl localhost:2019/load \
|
<pre><code class="cmd bash">curl localhost:2019/load \
|
||||||
-X POST \
|
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d @caddy.json
|
-d @caddy.json
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
|
@ -17,7 +17,6 @@ First start Caddy:
|
||||||
Caddy is currently running idle (with a blank configuration). Give it a simple config with `curl`:
|
Caddy is currently running idle (with a blank configuration). Give it a simple config with `curl`:
|
||||||
|
|
||||||
<pre><code class="cmd bash">curl localhost:2019/load \
|
<pre><code class="cmd bash">curl localhost:2019/load \
|
||||||
-X POST \
|
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d @- << EOF
|
-d @- << EOF
|
||||||
{
|
{
|
||||||
|
@ -44,7 +43,6 @@ EOF</code></pre>
|
||||||
Giving a POST body with [Heredoc](https://en.wikipedia.org/wiki/Here_document#Unix_shells) can be tedious, so if you prefer to use files, save the JSON to a file called `caddy.json` and then use this command instead:
|
Giving a POST body with [Heredoc](https://en.wikipedia.org/wiki/Here_document#Unix_shells) can be tedious, so if you prefer to use files, save the JSON to a file called `caddy.json` and then use this command instead:
|
||||||
|
|
||||||
<pre><code class="cmd bash">curl localhost:2019/load \
|
<pre><code class="cmd bash">curl localhost:2019/load \
|
||||||
-X POST \
|
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d @caddy.json
|
-d @caddy.json
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
|
@ -56,7 +56,6 @@ localhost:2016 {
|
||||||
You can give Caddy the updated configuration two ways, either with the API directly:
|
You can give Caddy the updated configuration two ways, either with the API directly:
|
||||||
|
|
||||||
<pre><code class="cmd bash">curl localhost:2019/load \
|
<pre><code class="cmd bash">curl localhost:2019/load \
|
||||||
-X POST \
|
|
||||||
-H "Content-Type: text/caddyfile" \
|
-H "Content-Type: text/caddyfile" \
|
||||||
--data-binary @Caddyfile
|
--data-binary @Caddyfile
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue