Skip to content

Routing doesn't merge routes with different parameter names #549

Open
@cy6erGn0m

Description

@cy6erGn0m

Example 1a

get("/{...}") {
    println("first")
}
get("/{...}") {
    println("second")
}

Example 2b

get("/{param...}") {
    println("first")
}
get("/{param...}") {
    println("second")
}

Accessing / or /path causes both handlers to print to the system output.

However changing parameter names makes it work completely different

Example 2

get("/{param1...}") {
    println("first")
}
get("/{param2...}") {
    println("second")
}

In this case only first handler is invoked while the second handler is filtered out.

The reason why it works like that is that in examples 1a and 1b both routes get merged into one so both handlers are actually added to a single route instance. In example 2 we have two different routes so route resolution takes the first one due to ambiguity.

The particular consequence of this issue is that user are unable to write custom directory index pages unlike they know exact parameter name that is private inside of static content routes implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    routinguxUser Experience issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions