Skip to content

Function: Header()

ts
function Header(name, value): MethodDecorator;

Defined in: packages/core/src/decorators/header.decorator.ts:26

Decorator that sets HTTP headers for the response.

Parameters

ParameterTypeDescription
namestringThe header name
valuestringThe header value

Returns

MethodDecorator

Example

typescript
@Get()
@Header('Cache-Control', 'none')
getData() {
  return { data: [] };
}

@Post()
@Header('Location', '/resource/123')
create() {
  return { id: 123 };
}

Released under the MIT License.