| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,3 +9,4 @@ _middleware_という拡張する仕組みを持っていて、connectが持つ | |||
| 9 | 9 | ||
| 10 | 10 | ## どう書ける? | |
| 11 | 11 | ||
| 12 | + [import, connect-inline-example.js](../../src/connect/connect-inline-example.js) | ||
| Original file line number | Diff line number | Diff 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 | + | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments