line / armeria

Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
https://armeria.dev
Apache License 2.0
4.8k stars 912 forks source link

Consider dropping `:` from path pattern #5710

Open ikhoon opened 4 months ago

ikhoon commented 4 months ago

: is useful to bind a path variable. However, : is a variable character for a path. If a path variable :foo is mixed with a literal :, it is ambiguous and difficult to know the exact scope of the variable, e.g. /api/v1/:project:get.

Currently, project:get is regarded as a path variable. It makes no sense because I believe most people intend to use project as the path variable and :get is an exact path match.

I don't see that it is inconvenient to only use {project} in a path pattern. Excluding : from path variables and using it only as literals would be a way to eliminate ambiguity and simplify our logic.

Instead, : could be used as a special character within {} to indicate the type of the parameter. https://github.com/line/armeria/blob/2112f50524cf9568ead7e2929fe6cb6f76e2c645/core/src/main/java/com/linecorp/armeria/server/ParameterizedPathMapping.java#L146