// curl -k https://localhost:8000/ | |
var https = require('https'); | |
var fs = require('fs'); | |
var options = { | |
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), | |
cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem') | |
}; | |
https.createServer(options, function (req, res) { | |
res.writeHead(200); | |
res.end("hello world\n"); | |
}).listen(8000); |
This comment has been minimized.
This comment has been minimized.
Impressively simple as always. |
This comment has been minimized.
This comment has been minimized.
yes! |
This comment has been minimized.
This comment has been minimized.
love it! |
This comment has been minimized.
This comment has been minimized.
+2 for simplicity |
This comment has been minimized.
This comment has been minimized.
I love this :) Good job! |
This comment has been minimized.
This comment has been minimized.
Awesome, can't wait to use it! |
This comment has been minimized.
This comment has been minimized.
Nice.. But wouldn't it be easier if it was directly exposed in the http module instead of separate https? eg:
|
This comment has been minimized.
This comment has been minimized.
what's the difference between module tls and https? |
This comment has been minimized.
This comment has been minimized.
@yyliang https is to tls as http is to net |
This comment has been minimized.
This comment has been minimized.
the options should be the second argument of |
This comment has been minimized.
This comment has been minimized.
@visionmedia If options were optional, I'd agree. But, since key and cert are required config, making it the first parameter makes more sense because the requestListener function is more readable as the final parameter IMHO. Perhaps not calling the first parameter "options" would make that more clear. |
This comment has been minimized.
This comment has been minimized.
actually yeah i guess it depends how large your function is, I was just thinking it makes more sense for complying with the http server api, and then just tacking the options on, more elegant to support both that way |
This comment has been minimized.
This comment has been minimized.
Right on. Good point. |
This comment has been minimized.
This comment has been minimized.
visionmedia++ |
This comment has been minimized.
This comment has been minimized.
Nice. Not so sure about the options arg last. Yes, its more like the http-server api, but it just looks ugly - and feels unatural when reading and have to jump way down to read the second parameter. Cheers:) |
This comment has been minimized.
This comment has been minimized.
"callbacks last"++ -- it really helps when using CoffeeScript |
This comment has been minimized.
This comment has been minimized.
it just looks ugly? do you realize which language you are using lol think of it this way:
options can be safely ignore when http, but support simple swapping for https |
This comment has been minimized.
This comment has been minimized.
Only slight longer, but very clear and simple:
|
This comment has been minimized.
This comment has been minimized.
In my puny head, it makes my eyes jump around more than the first example - I, imho, like when I can see input first, and then apply those to what I see inside the "output". Altough I see your point(both), for me at least input-output trumphs those now. Convince me otherwise :).
|
This comment has been minimized.
This comment has been minimized.
yeah that looks better |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
dude that is nasty lol wtf |
This comment has been minimized.
This comment has been minimized.
It is very sweet the way it is, just like we are used with require('http'). |
This comment has been minimized.
beautiful!!