mirror of
https://github.com/caddyserver/caddy.git
synced 2026-10-03 21:06:49 +00:00
caddyfile: Implement heredoc support (#5385)
This commit is contained in:
parent
9e6919550b
commit
960150bb03
12 changed files with 397 additions and 135 deletions
50
caddytest/integration/caddyfile_adapt/heredoc.txt
Normal file
50
caddytest/integration/caddyfile_adapt/heredoc.txt
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
example.com {
|
||||
respond <<EOF
|
||||
<html>
|
||||
<head><title>Foo</title>
|
||||
<body>Foo</body>
|
||||
</html>
|
||||
EOF 200
|
||||
}
|
||||
----------
|
||||
{
|
||||
"apps": {
|
||||
"http": {
|
||||
"servers": {
|
||||
"srv0": {
|
||||
"listen": [
|
||||
":443"
|
||||
],
|
||||
"routes": [
|
||||
{
|
||||
"match": [
|
||||
{
|
||||
"host": [
|
||||
"example.com"
|
||||
]
|
||||
}
|
||||
],
|
||||
"handle": [
|
||||
{
|
||||
"handler": "subroute",
|
||||
"routes": [
|
||||
{
|
||||
"handle": [
|
||||
{
|
||||
"body": "\u003chtml\u003e\n \u003chead\u003e\u003ctitle\u003eFoo\u003c/title\u003e\n \u003cbody\u003eFoo\u003c/body\u003e\n\u003c/html\u003e\n",
|
||||
"handler": "static_response",
|
||||
"status_code": 200
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"terminal": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
(logging) {
|
||||
log {
|
||||
output file /var/log/caddy/{args.0}.access.log
|
||||
output file /var/log/caddy/{args[0]}.access.log
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ https://example.com {
|
|||
method GET
|
||||
rewrite /rewritten?uri={uri}
|
||||
|
||||
buffer_requests
|
||||
request_buffers 4KB
|
||||
|
||||
transport http {
|
||||
read_buffer 10MB
|
||||
|
|
@ -54,7 +54,6 @@ https://example.com {
|
|||
{
|
||||
"handle": [
|
||||
{
|
||||
"buffer_requests": true,
|
||||
"handler": "reverse_proxy",
|
||||
"headers": {
|
||||
"request": {
|
||||
|
|
@ -68,6 +67,7 @@ https://example.com {
|
|||
}
|
||||
}
|
||||
},
|
||||
"request_buffers": 4000,
|
||||
"rewrite": {
|
||||
"method": "GET",
|
||||
"uri": "/rewritten?uri={http.request.uri}"
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
respond "'I am {args.0}', hears {args.1}"
|
||||
respond "'I am {args[0]}', hears {args[1]}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue