Skip to content

Commit

Permalink
feat(connect): インラインにmiddlewareを書いたexampleを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Sep 12, 2015
1 parent 956c796 commit 8556137
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions ja/connect/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ _middleware_という拡張する仕組みを持っていて、connectが持つ

## どう書ける?

[import, connect-inline-example.js](../../src/connect/connect-inline-example.js)
18 changes: 18 additions & 0 deletions src/connect/connect-inline-example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use strict";
import assert from "assert";
import connect from "connect";
import http from "http";
var app = connect();
// add "X-Content-Type-Options" to response
app.use(function (req, res, next) {
res.setHeader("X-Content-Type-Options", "nosniff");
next(); // => next middleware
});
// respond to all requests
app.use(function (req, res) {
res.end("response text");
});
//create node.js http server and listen on port
http.createServer(app).listen(3000);


0 comments on commit 8556137

Please sign in to comment.