caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
55.53k stars 3.91k forks source link

Snippets can't be imported in named routes #6431

Open loichyan opened 2 days ago

loichyan commented 2 days ago

Description

import is not recognized in named routes. With the following configuration:

# Caddyfile
(mysnippet) {
    encode zstd gzip
}

&(myroute) {
    import mysnippet
    respond "Hello, Caddy!"
}

example.com {
    invoke myroute
}

It results in:

$ caddy adapt -c Caddyfile
Error: unrecognized directive: import - are you sure your Caddyfile structure (nesting and braces) is correct?, at config/caddy/Caddyfile:8

Environment

I also reproduced it on the latest commit (https://github.com/caddyserver/caddy/commit/f8861ca16bd475e8519e7dbf5a2b55e81b329874).