1. The problem I’m having:
I am trying to create multiple redirects at one time via the API. I can do one at a time like this:
curl -X PUT \
-H "Content-Type: application/json" \
-d @redir.json \
"http://localhost:2019/id/example.com/handle/0/routes/0"
Using this JSON payload:
{
"handle": [
{
"handler": "static_response",
"headers": {
"Location": [
"/goodbye/"
]
},
"status_code": 302
}
],
"match": [
{
"path": [
"/hello/"
]
}
]
}
This works correctly and adds a new redirect. I want to be able to submit multiple redirects at one time.
2. Error messages and/or full log output:
I just can’t figure out how to do it. I want to be able to give it multiple new redirects like this, which obviously doesn’t work {"error":"[/config/apps/http/servers/srv0/routes/0/handle/0/routes] key already exists: routes"}
:
curl -X PUT \
-H "Content-Type: application/json" \
-d @redir.json \
"http://localhost:2019/id/example.com/handle/0/routes"
and the payload
[
{
"handle": [
{
"handler": "static_response",
"headers": {
"Location": [
"/goodbye/"
]
},
"status_code": 302
}
],
"match": [
{
"path": [
"/hello/"
]
}
]
},
{
"handle": [
{
"handler": "static_response",
"headers": {
"Location": [
"/iam/"
]
},
"status_code": 302
}
],
"match": [
{
"path": [
"/cool/"
]
}
]
}
]
3. Caddy version:
v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=