mirror of
https://github.com/caddyserver/website.git
synced 2025-04-27 23:46:16 -04:00
Add documentation for the set
option in request_body
directive (#468)
This commit is contained in:
parent
044d0c2fce
commit
78b4adfac6
1 changed files with 21 additions and 1 deletions
|
@ -6,17 +6,19 @@ title: request_body (Caddyfile directive)
|
||||||
|
|
||||||
Manipulates or sets restrictions on the bodies of incoming requests.
|
Manipulates or sets restrictions on the bodies of incoming requests.
|
||||||
|
|
||||||
|
|
||||||
## Syntax
|
## Syntax
|
||||||
|
|
||||||
```caddy-d
|
```caddy-d
|
||||||
request_body [<matcher>] {
|
request_body [<matcher>] {
|
||||||
max_size <value>
|
max_size <value>
|
||||||
|
set <body_content>
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- **max_size** is the maximum size in bytes allowed for the request body. It accepts all size values supported by [go-humanize](https://pkg.go.dev/github.com/dustin/go-humanize#pkg-constants). Reads of more bytes will return an error with HTTP status `413`.
|
- **max_size** is the maximum size in bytes allowed for the request body. It accepts all size values supported by [go-humanize](https://pkg.go.dev/github.com/dustin/go-humanize#pkg-constants). Reads of more bytes will return an error with HTTP status `413`.
|
||||||
|
|
||||||
|
⚠️ <i>Experimental</i> <span style='white-space: pre;'> | </span> <span>v2.10.0+</span>
|
||||||
|
- **set** allows setting the request body to specific content. The content can include placeholders to dynamically insert data.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -30,3 +32,21 @@ example.com {
|
||||||
reverse_proxy localhost:8080
|
reverse_proxy localhost:8080
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Set the request body with a JSON structure containing a SQL query:
|
||||||
|
|
||||||
|
```caddy
|
||||||
|
example.com {
|
||||||
|
handle /jazz {
|
||||||
|
request_body {
|
||||||
|
set `\{"statementText":"SELECT name, genre, debut_year FROM artists WHERE genre = 'Jazz'"}`
|
||||||
|
}
|
||||||
|
|
||||||
|
reverse_proxy localhost:8080 {
|
||||||
|
header_up Content-Type application/json
|
||||||
|
method POST
|
||||||
|
rewrite * /execute-sql
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue