Skip to content

Add @Headers() decorator overload(s) that support Pipes #15193

@ori88c

Description

@ori88c

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

Currently, the @Headers() decorator does not support passing Pipes, unlike other route parameter decorators such as @Query(), @Param(), and @Body().
Reference:
https://github.com/nestjs/nest/blob/master/packages/common/decorators/http/route-params.decorator.ts#L325
For comparison, here's an overload of @query() that does support Pipes:
https://github.com/nestjs/nest/blob/master/packages/common/decorators/http/route-params.decorator.ts#L386-L389

Describe the solution you'd like

Add @Headers() decorator overload(s) that support Pipes. To fully support this enhancement, Paramtype would also need to be extended to include 'headers':
https://github.com/nestjs/nest/blob/master/packages/common/interfaces/features/paramtype.interface.ts#L4
This is important because the Paramtype value is passed via the ArgumentMetadata parameter to any PipeTransform:
https://github.com/nestjs/nest/blob/master/packages/common/interfaces/features/pipe-transform.interface.ts#L44

Teachability, documentation, adoption, migration strategy

.

What is the motivation / use case for changing the behavior?

Adding Pipe support to @Headers() would bring it to feature parity with the other route parameter decorators.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions