Skip to content

Support @PathVariable in Functional Closures Returned by WebFlux Endpoints #35122

Closed as not planned
@zapphyre

Description

@zapphyre

Allow @PathVariable, @RequestParam, and similar annotations on parameters of functional closures (e.g., Consumer, Function) returned by Spring WebFlux endpoints.

Motivation:

Spring WebFlux’s functional endpoints lack support for annotating closure parameters with @PathVariable. This forces developers to pass parameters explicitly, making code less concise. For example:

@PutMapping("decrement/{word}")
public Consumer<@PathVariable("word") String> adjustVocabDown(@PathVariable("langId") Long langId) {
    return word -> languageService.propVocabularyFreq(langId, changeFrequency.apply(decrement)).accept(word);
}

Supporting annotations in closures would simplify endpoint definitions and align with Spring MVC’s annotation model.

Proposed Solution:

Enable Spring (WebFlux, Web) to process @PathVariable, @RequestParam, and @RequestBody on closure type parameters. Bind request data (e.g., path variables) to these parameters automatically, similar to annotated controllers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions