Skip to content

Commit 8556137

Browse files
committed
feat(connect): インラインにmiddlewareを書いたexampleを追加
1 parent 956c796 commit 8556137

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

ja/connect/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ _middleware_という拡張する仕組みを持っていて、connectが持つ
99

1010
## どう書ける?
1111

12+
[import, connect-inline-example.js](../../src/connect/connect-inline-example.js)

src/connect/connect-inline-example.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"use strict";
2+
import assert from "assert";
3+
import connect from "connect";
4+
import http from "http";
5+
var app = connect();
6+
// add "X-Content-Type-Options" to response
7+
app.use(function (req, res, next) {
8+
res.setHeader("X-Content-Type-Options", "nosniff");
9+
next(); // => next middleware
10+
});
11+
// respond to all requests
12+
app.use(function (req, res) {
13+
res.end("response text");
14+
});
15+
//create node.js http server and listen on port
16+
http.createServer(app).listen(3000);
17+
18+

0 commit comments

Comments
 (0)