Last active
June 14, 2018 02:50
-
-
Save CarterLi/43e4eb1a74265d15a8ff7313e500bb6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function foo(req, res) { | |
req.log("hello from foo() handler"); | |
return "foo"; | |
} | |
function summary(req, res) { | |
var a, s, h; | |
s = "JS summary\n\n"; | |
s += "Method: " + req.method + "\n"; | |
s += "HTTP version: " + req.httpVersion + "\n"; | |
s += "Host: " + req.headers.host + "\n"; | |
s += "Remote Address: " + req.remoteAddress + "\n"; | |
s += "URI: " + req.uri + "\n"; | |
s += "Headers:\n"; | |
for (h in req.headers) { | |
s += " header '" + h + "' is '" + req.headers[h] + "'\n"; | |
} | |
s += "Args:\n"; | |
for (a in req.args) { | |
s += " arg '" + a + "' is '" + req.args[a] + "'\n"; | |
} | |
return s; | |
} | |
function baz(req, res) { | |
res.headers.foo = 1234; | |
res.status = 200; | |
res.contentType = "text/plain; charset=utf-8"; | |
res.contentLength = 15; | |
res.sendHeader(); | |
res.send("nginx"); | |
res.send("java"); | |
res.send("script"); | |
res.finish(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes auto; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
js_include http.js; | |
js_set $foo foo; | |
js_set $summary summary; | |
server { | |
listen 7000; | |
location / { | |
add_header X-Foo $foo; | |
js_content baz; | |
} | |
location /summary { | |
return 200 $summary; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment