Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Start on getting middleware working as before/after filters

  • Loading branch information...
commit c3dbd72c3adfecf3a4bf21a9945f93bfb8a23bd2 1 parent 77e79ea
mde authored
Showing with 27 additions and 17 deletions.
  1. +0 −1  lib/app.js
  2. +10 −16 lib/request.js
  3. +17 −0 test/request.js
View
1  lib/app.js
@@ -25,7 +25,6 @@ var fs = require('fs')
, cwd = process.cwd()
, errors = require('./response/errors')
, response = require('./response')
- , utils = require('utilities')
, init = require('./init')
, helpers = require('./template/helpers')
, actionHelpers = require('./template/helpers/action')
View
26 lib/request.js
@@ -1,23 +1,17 @@
var EventBuffer = require('utilities').EventBuffer
- , EventEmitter = require('events').EventEmitter;
+ , EventEmitter = require('events').EventEmitter
+ , ServerRequest = require('http').IncomingMessage
+ , utils = require('utilities');
-var Request = function (httpReq) {
- var self = this
- , reqProperties = [
- 'method'
- , 'url'
- , 'headers'
- , 'trailers'
- , 'httpVersion'
- , 'connection'
- ];
- this.buffer = new EventBuffer(httpReq);
- reqProperties.forEach(function (prop) {
- self[prop] = httpReq[prop];
- });
+var Request = function (req) {
+ // Copy props over from original
+ utils.mixin(this, req);
+ // Set up buffering
+ this.buffer = new EventBuffer(req);
};
-Request.prototype = new EventEmitter();
+// Inherit from actual ServerRequest
+Request.prototype = new ServerRequest();
Request.prototype.constructor = Request;
Request.prototype.sync = function () {
View
17 test/request.js
@@ -0,0 +1,17 @@
+var assert = require('assert')
+ , Request = require('../lib/request').Request
+ , ServerRequest = require('http').IncomingMessage
+ , tests;
+
+tests = {
+ 'create instance': function () {
+ var serverReq = new ServerRequest()
+ , req = new Request(serverReq);
+ assert.ok(req instanceof Request);
+ }
+
+};
+
+module.exports = tests;
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.