Skip to content

Support data binding from request headers #32676

Closed
@kalgon

Description

@kalgon

Affects: 6.1.5

A rest controller with the following method

    @GetMapping("/{path}")
    public void get(Params params, @PathVariable long path, @RequestParam String foo, @RequestHeader String accept) {
        System.out.printf("path: %d%n", path);
        System.out.printf("foo: %s%n", foo);
        System.out.printf("accept: %s%n", accept);
        System.out.printf("params: %s%n", params);
    }
    public record Params(@PathVariable long path, @RequestParam String foo, @RequestHeader String accept) {}

will produce the following log when called with /1?foo=FOO:

    path: 1
    foo: FOO
    accept: application/json, text/plain, */*
    params: Params[path=1, foo=FOO, accept=null]

@PathVariable and @RequestParam are correctly used to instantiate the record but the @RequestHeader remains null (although it works as a parameter of the controller method)

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