Skip to content

Placeholder shorthands are not replaced in named routes #5788

@pkoenig10

Description

@pkoenig10

The following Caddyfile:

&(named) {
    vars Test {header.test}
}

example.com {
    invoke named
    vars Test {header.test}
}

Produces the following config:

{
    "apps": {
        "http": {
            "servers": {
                "srv0": {
                    "listen": [
                        ":443"
                    ],
                    "routes": [
                        {
                            "match": [
                                {
                                    "host": [
                                        "example.com"
                                    ]
                                }
                            ],
                            "handle": [
                                {
                                    "handler": "subroute",
                                    "routes": [
                                        {
                                            "handle": [
                                                {
                                                    "Test": "{http.request.header.test}",
                                                    "handler": "vars"
                                                },
                                                {
                                                    "handler": "invoke",
                                                    "name": "named"
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ],
                            "terminal": true
                        }
                    ],
                    "named_routes": {
                        "named": {
                            "handle": [
                                {
                                    "Test": "{header.test}",
                                    "handler": "vars"
                                }
                            ]
                        }
                    }
                }
            }
        }
    }
}

I see that named routes are still an experimental feature, so I'm not sure if this behavior is intentional or a known limitation.

If this is not a bug, I think it would be helpful to call out in the documentation. It took me while to debug why my placeholders were not working as I would have expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐞Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions