Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8556137

Browse files
committed
feat(connect): インラインにmiddlewareを書いたexampleを追加
1 parent956c796 commit8556137

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

‎ja/connect/README.md

Lines changed: 1 addition & 0 deletions
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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"use strict";
2+
importassertfrom"assert";
3+
importconnectfrom"connect";
4+
importhttpfrom"http";
5+
varapp=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)

[8]ページ先頭

©2009-2025 Movatter.jp