라우팅

유석현(SeokHyun Yu)·2022년 12월 21일
0

Nest.js

목록 보기
3/9
post-thumbnail
post-custom-banner

1. 기본값

import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';

// http://localhost:8000
@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}
  @Get()
  getHello(): string {
    return 'hello';
  }
}


2. @Get()

import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';

// http://localhost:8000/cat
@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}
  
  @Get('cat')
  getHello(): string {
    return 'hello';
  }
}


3. @Controller()

import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';

// http://localhost:8000/animal/cat
@Controller('animal')
export class AppController {
  constructor(private readonly appService: AppService) {}
  
  @Get('cat')
  getHello(): string {
    return 'hello';
  }
}

profile
Backend Engineer
post-custom-banner

0개의 댓글