在请求里面自定义添加headers,Authorization和X-Hello,程序收到的是小写的authorization及x-hello,装饰器不加参数是全部对象,加参数是获取某一个头部信息,获取多个怎么拿?

This commit is contained in:
Jeremy Yin 2019-06-17 23:09:23 +08:00
parent 245af79f31
commit 585c6f6b28
1 changed files with 1 additions and 1 deletions

View File

@ -3,7 +3,7 @@ import { Controller, Get, Req, Query, Headers } from '@nestjs/common';
@Controller('posts')
export class PostsController {
@Get()
index(@Headers() headers, @Query() query) {
index(@Headers('authorization') headers, @Query() query) {
console.log(headers)
console.log(query)
return [