반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- react #useCallback #react Hook
- react
- 노마드 코더 #타입스크립트 #typescript #class
- React-Query
- React #Hook rules #Hook 규칙
- RateLimit
- React #controlled component #비제어 컴포넌트 #제어 컴포넌트
- rate limit
- donwstream #upstream #origin
- axios
- React #effect hook #useEffect
- 코드스테이츠 #알고리즘 #그리디
- 백준 #적록색약
- react fragment
- interceptors
- 이친수
- DP #c++
- 버블링 #갭쳐링 #이벤트 #JS
- 얕은 복사 #깊은 복사 #shallow copy #deep copy
- useState #Hooks
- raect typescript #react #typescript #styled-component
- npm #not being able to find a file #npm install Error
- 빡킹독
- 백준 #직각삼각형
- JWT #토큰 #refreshToken #accessToken #Token #token #localStorage #sessionStorage
- html entities
- 다익스트라 #파티 #백준
- React #리액트 이벤트 주기 #리액트 이벤트
- 플로이드 #c++
- #useRef #언제 쓰는데?
Archives
- Today
- Total
꿈꾸는 개발자
기본 라우팅(express) 본문
라우팅:
라우팅은 application endpoint URI(경로) 및 특정한 HTTP 요청 메서드(GET, POST 등)인 특정 엔드포인테 대한 client 요청에 application이 응답하는 방법을 결정하는 것을 말한다.
각 라우터는 하나 이상의 헨들러를 가질 수 있다 => 라우터가 일치할 때 실행되는 콜백함수(헨들러)를 뜻한다.
app.METHOD(PATH, HANDLER)
- app은 express의 instance
- METHOD는 HTTP 요청 메서드(기본적으로, GET, POST, PUT, PATCH, DELELTE 등이 있음)
- PATH는 서버에서 경로를 의미한다
- HANDLER는 위에서 설명했듯이 라우터가 일치했을 때 실행되는 함수를 의미한다
HTTP 메서드 별 예시:
app.get('/', function (req, res) {
res.send('Hello World!');
});
- 홈페이지의 라우터가 일치될 경우 res.send("hello world")을 응답하는 코드이다(req === request/ res ===response)
app.post('/', function (req, res) {
res.send('Got a POST request');
});
app.put('/user', function (req, res) {
res.send('Got a PUT request at /user');
});
app.delete('/user', function (req, res) {
res.send('Got a DELETE request at /user');
});
출처:
https://expressjs.com/ko/starter/basic-routing.html
Express 기본 라우팅
기본 라우팅 라우팅은 URI(또는 경로) 및 특정한 HTTP 요청 메소드(GET, POST 등)인 특정 엔드포인트에 대한 클라이언트 요청에 애플리케이션이 응답하는 방법을 결정하는 것을 말합니다. 각 라우트
expressjs.com