Skip to content
Browse files

[api]SPDY support via node-spdy

  • Loading branch information...
1 parent d57d3ea commit 23c1ca9c090dabe5f8a85c1e14a0df90a1d1706c @pkrefta pkrefta committed Jul 2, 2012
Showing with 28 additions and 8 deletions.
  1. +28 −8 lib/core.js
View
36 lib/core.js
@@ -1,5 +1,5 @@
/*
- * core.js: Core functionality for the Flatiron HTTP plugin.
+ * core.js: Core functionality for the Flatiron HTTP (with SPDY support) plugin.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
@@ -50,18 +50,38 @@ core.createServer = function (options) {
req.pipe(routingStream);
}
- if (options.https) {
- if (!options.https.key || !options.https.cert) {
- throw new Error('Both `options.https.key` and `options.https.cert` are required.');
+ //
+ // both https and spdy requires same params
+ //
+ if (options.https || options.spdy) {
+
+ var key;
+
+ if(options.spdy) {
+ key = 'spdy';
+ } else {
+ key = 'https';
+ }
+
+ server_options = options[key];
+
+ if (!server_options.key || !server_options.cert) {
+ throw new Error('Both options.'+key+'.`key` and options.'+key+'.`cert` are required.');
}
credentials = {
- key: fs.readFileSync(options.https.key),
- cert: fs.readFileSync(options.https.cert)
+ key: fs.readFileSync(server_options.key),
+ cert: fs.readFileSync(server_options.cert)
};
- if (options.https.ca) {
- credentials.ca = fs.readFileSync(options.https.ca);
+ if (server_options.ca) {
+ credentials.ca = fs.readFileSync(server_options.ca);
+ }
+
+ if(options.spdy){
+ // spdy is optional so we require module here rather than on top
+ var spdy = require('spdy');
+ return spdy.createServer(credentials, requestHandler);
}
return https.createServer(credentials, requestHandler);

0 comments on commit 23c1ca9

Please sign in to comment.
Something went wrong with that request. Please try again.