flatiron/flatiron — pull request #68 by egildo (2012-06-10 10:55:17+00:00)
Title: Flatiron.js HTTPS server

Union's createServer has [the following options](https://github.com/flatiron/union#createserveroptions):
@option before {Array}
@option after {Array}
@option limit {Object}
**@option https {Object}**
@option headers {Object}
At the same time there's no **https** in `lib/flatiron/plugins/http.js`:
```
app.createServer = function(){
app.server = union.createServer({
//
// -> OPTIONS:
// -> after, before, headers and limit
// -> https is missed
//
after: app.http.after,
before: app.http.before.concat(function (req, res) {
if (!app.router.dispatch(req, res, app.http.onError || union.errorHandler)) {
if (!app.http.onError) res.emit('next');
}
}),
headers: app.http.headers,
limit: app.http.limit
});
};
```
I added just 1 line of code to `lib/flatiron/plugins/http.js`. Now it's possible to create an HTTPS server in the following way:
```js
var flatiron = require('flatiron'),
app = flatiron.app;

app.use(flatiron.plugins.http, {
https: {
cert: 'path/to/cert.pem',
key: 'path/to/key.pem',
ca: 'path/to/ca.pem'
}
});

app.router.get('/', function () {
this.res.writeHead(200, { 'Content-Type': 'text/plain' });
this.res.end('Hello world!\n');
});

app.start(443);
```