Skip to content

Add leading slash for path predicate if not present #22795

Closed
@hantsy

Description

@hantsy

I have tried the latest Kotlin Coroutines, but I encountered a small issue when using coRouter DSL.

Spring Boot 2.2.0.BUILD-SNAPSHOT, Spring 5.2.0.M1, Kotlin 1.3, Java 8

For the nest path, I have to append "/" to make it work. Check the source codes here.

    @Bean
    fun routes(postHandler: PostHandler) = coRouter {
        "/posts".nest {
            GET("", postHandler::all)
            GET("/{id}", postHandler::get)
            POST("", postHandler::create)
            PUT("/{id}", postHandler::update)
            DELETE("/{id}", postHandler::delete)
        }

But in my before experience, for nest paths, it should work without a "/" prefix in both annotated controllers and router DSL, example.

 fun routes() = router {
        "/posts".nest {
            GET("", postHandler::all)
            GET("{id}", postHandler::get)
            POST("", postHandler::create)
            PUT("{id}", postHandler::update)
            DELETE("{id}", postHandler::delete)
        }
}

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions