Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add leading slash for path predicate if not present #22795

Closed
hantsy opened this issue Apr 15, 2019 · 2 comments
Closed

Add leading slash for path predicate if not present #22795

hantsy opened this issue Apr 15, 2019 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@hantsy
Copy link
Contributor

hantsy commented Apr 15, 2019

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)
        }
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 15, 2019
@sdeleuze sdeleuze self-assigned this Apr 15, 2019
@sdeleuze sdeleuze added this to the 5.2 M2 milestone Apr 15, 2019
@sdeleuze sdeleuze added in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 15, 2019
@sdeleuze
Copy link
Contributor

Based on my tests with both Spring Boot 2.1.4 and 2.2.0.M2, it seems you have to currently append / to make it work for all variants : WebFlux.fn Reactive, WebFlux.fn Coroutines or WebMvc.fn.

That said, maybe we could turn this issue into an improvement one to make functional routing more lenient when the leading slash is not specified.

Any thoughts @poutsma?

@poutsma
Copy link
Contributor

poutsma commented Apr 25, 2019

Any thoughts @poutsma?

Sounds good to me.

@poutsma poutsma added type: enhancement A general enhancement and removed type: bug A general bug labels Apr 25, 2019
@poutsma poutsma assigned poutsma and unassigned sdeleuze Apr 25, 2019
@sdeleuze sdeleuze changed the title Path resolving issue when using Kotlin Coroutines with Kotlin DSL. Improve functional routing to add automatically leading separator if needed Apr 25, 2019
@poutsma poutsma modified the milestones: 5.2 M2, 5.2 M3 May 8, 2019
@poutsma poutsma changed the title Improve functional routing to add automatically leading separator if needed Add leading slash for path predicate if not present May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants