瀏覽代碼

restify fixes

Michelle Bu 12 年之前
父節點
當前提交
24805444cc
共有 1 個文件被更改,包括 3 次插入10 次删除
  1. 3 10
      lib/server.js

+ 3 - 10
lib/server.js

@@ -10,7 +10,6 @@ function PeerServer(options) {
   EventEmitter.call(this);
   EventEmitter.call(this);
 
 
   this._app = restify.createServer();
   this._app = restify.createServer();
-  //this._app = express();
   this._httpServer = this._app;
   this._httpServer = this._app;
 
 
   this._options = util.extend({
   this._options = util.extend({
@@ -181,20 +180,14 @@ PeerServer.prototype._checkKey = function(key, ip, cb) {
   }
   }
 }
 }
 
 
-//This is where we change to restify
 /** Initialize HTTP server routes. */
 /** Initialize HTTP server routes. */
 PeerServer.prototype._initializeHTTP = function() {
 PeerServer.prototype._initializeHTTP = function() {
   var self = this;
   var self = this;
   
   
-  //this._app.use(express.bodyParser());
+  this._app.use(restify.bodyParser({ mapParams: false }));
+  this._app.use(restify.queryParser())
   this._app.use(util.allowCrossDomain);
   this._app.use(util.allowCrossDomain);
-  
-  /*this._app.options('/*', function(req, res, next) {
-    res.send(200);
-    return next();
-  });*/
 
 
-  
   // Retrieve guaranteed random ID.
   // Retrieve guaranteed random ID.
   this._app.get('/:key/id', function(req, res, next) {
   this._app.get('/:key/id', function(req, res, next) {
     res.contentType = 'text/html';
     res.contentType = 'text/html';
@@ -270,7 +263,7 @@ PeerServer.prototype._initializeHTTP = function() {
 
 
   //this._app.post('/port', handle);
   //this._app.post('/port', handle);
   
   
-  // Listen on user-specified port and 
+  // Listen on user-specified port.
   this._httpServer.listen(this._options.port);
   this._httpServer.listen(this._options.port);
   
   
 };
 };