@Controller('hello')
export class HelloController {
@Get()
get(): string {
return 'get';
}
@Post()
create(): string {
return 'create';
}
@Put()
update(): string {
return 'update';
}
@Delete()
remove(): string {
return 'remove';
}
}
@Controller
데코레이터 사용
모든 표준 HTTP 메서드를 데코레이터 제공
// 예시 /hello/coolmarvel?country=korea
@Get(':name')
get(@Param('name') name: string, @Query('country') country: string) {
return `my name is ${name} from ${country};
}
@Param
: 매개변수
@Query
: 쿼리스트링