If I remove the backslash from the Caddyfile, I get the following output. Why is {vars.b} replaced with its value in the first occurrence (line 3) and produces nothing in the other?
Where can I learn more about these kind of things? I searched the docs but only found shallow documentation.
2. Error messages and/or full log output:
* Trying [::1]:2222...
* Connected to localhost (::1) port 2222
> GET / HTTP/1.1
> Host: localhost:2222
> User-Agent: curl/8.4.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/plain; charset=utf-8
< Server: Caddy
< Date: Thu, 30 Nov 2023 21:43:48 GMT
< Content-Length: 38
<
:2222
vars b "`"
* Connection #0 to host localhost left intact
vars x {http.vars.b}y%
3. Caddy version:
v2.7.5
4. How I installed and ran Caddy:
Using pacman with the official repositories
a. System environment:
Arch linux
b. Command:
caddy watch
c. Service/unit/compose file:
N/A
d. My complete Caddy config:
:2222
vars b "`"
vars x `{vars.b}"
vars x \{vars.b}`
respond `:2222
vars b "{vars.b}{vars.x}y`
The Caddyfile has placeholder shortcuts like {vars.*} which expand to their real value {http.vars.*}. See Caddyfile Concepts — Caddy Documentation which explains.
Directives in the Caddyfile are sorted. This means that the order you place directives in your Caddyfile isn’t necessarily the order it runs in. The algorithm is explained here: Caddyfile Directives — Caddy Documentation
But also your Caddyfile has really wacky syntax. I don’t really understand what you’re trying to do. You’re using double quotes and backticks in strange ways.
What are you trying to do exactly? I don’t find it clear from your example.
When the Caddyfile parser finds a backtick, it’ll read characters up until it finds another backtick. If it finds a double-quote, it’ll read characters up until it finds another double-quote. One doesn’t close the other (which it feels like you’re trying to do with that example?? So confusing…)
I know it’s whacky. I’m trying to write a Quine, that is, a program that outputs it’s code. The string literals for vars x and respond directives are supposed to cover two lines respectively. I’m just confused about the order of the variable substitution.