Skip to Content
한 권으로 끝내는 Node & Express: 웹사이트 구축을 위한 서버 사이드 자바스크립트
book

한 권으로 끝내는 Node & Express: 웹사이트 구축을 위한 서버 사이드 자바스크립트

by 한성용, 이선 브라운
April 2016
Beginner to intermediate
389 pages
9h 8m
Korean
Hanbit Media, Inc.
Content preview from 한 권으로 끝내는 Node & Express: 웹사이트 구축을 위한 서버 사이드 자바스크립트
92
한 권으로 끝내는 Node & Express
6.7.
매개변수
‘매개변수’라는 단어의 뜻은 아주 다양하며 종종 혼란을 일으킵니다. 어떤 요청이든, 매개변수
는 쿼리스트링에도 들어 있고 세션(쿠키 필요,
9
장에서 다룹니다)에도 들어 있으며 요청 본문
이나 이름 붙은
named
라우팅 매개변수(
14
장에서 더 설명합니다)에도 들어 있습니다. 노드 애플
리케이션에는 이들 매개변수를 요청 객체 하나로 묶는
param
메서드가 있습니다. 필자는 이 메
서드를 쓰지 않길 권합니다. 이름이 같은 매개변수가 쿼리스트링에도 들어 있고
POST
본문이나
세션에도 들어 있다면 대체 어느 값이 선택될까요? 정말 골치 아픈 버그가 생길 수 있습니다.
이 혼란은 상당 부분
PHP
에서 비롯됐습니다.
PHP
는 ‘편리함’을 목적으로 이들 매개변수를 모
$
_
REQUEST
변수에 묶었으며, 이걸 좋은 아이디어라고 생각하는 사람들이 있었습니다. 다양
한 매개변수 타입마다 이를 저장하는 전용 프로퍼티가 있으며, 이에 대해 배울 것입니다. 필자
는 이 방법이 훨씬 덜 혼란스럽다고 생각합니다.
6.8.
요청 객체
요청 객체는 일반적으로 콜백에 전달되므로 이름은 원하는 대로 정해도 됩니다. 보통
req
이나
request
를 씁니다. 요청 객체는 핵심 노드 객체인
http
.
IncomingMessage
인스턴스에서 시작
하며 익스프레스에서 기능을 추가합니다. 요청 객체의 가장 유용한 프로퍼티와 메서드를 살펴
봅시다. 이들 메서드는 대부분 익스프레스에서 추가한 것인데,
req
.
headers ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것

한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것

한선용, 이선 브라운

Publisher Resources

ISBN: 9788968482229