Legacy/Node.js
-
express ejs에서 PJAX 사용시 header 및 footer 조건부 include하기Legacy/Node.js 2017. 1. 14. 21:12
라고 해주면 조건부로 include를 할 수 있다.그 이유는?위와 같이 PJAX 요청을 날릴 경우X-PJAX: true라는 헤더값이 request에 들어가 있기 때문에 구분할 수 있다.때문에 일반적인 요청에는 Header, Footer를 집어넣고, PJAX요청에는 내용만 가져오도록 할 수 있다. refhttp://pjax.herokuapp.com/https://github.com/defunkt/jquery-pjaxhttps://github.com/MoOx/pjaxhttps://ntotten.com/2012/04/09/building-super-fast-web-apps-with-pjax/ http://ejs.co/
-
Express의 미들웨어들Legacy/Node.js 2017. 1. 14. 01:49
참고 - [3판] 모던 웹을 위한 Node.js 프로그래밍 (윤인성) Express의 미들웨어들 - http://expressjs.com/en/resources/middleware.html 1. router 미들웨어 Express에 내장되어 있는 미들웨어로 별로 미들웨어라는 느낌을 받지 않고 사용할 수 있음.추가적인 모듈 설치 및 require 없이 app.get(), app.post() 등과 같은 메소드 호출만 필요함. // 모듈을 추출합니다. var express = require('express'); // 서버를 생성합니다. var app = express(); // 라우터를 설정합니다. app.get('/a', function (request, response) { response.send('Go..