Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for request-received middleware #200

Open
niftylettuce opened this issue Jun 13, 2019 · 2 comments
Open

Add support for request-received middleware #200

niftylettuce opened this issue Jun 13, 2019 · 2 comments

Comments

@niftylettuce
Copy link
Member

@niftylettuce niftylettuce commented Jun 13, 2019

The request-received middleware at https://github.com/cabinjs/request-received exposes a Symbol.for property, which this package could conditionally consume if interested (as opposed to just generating a new Date().

The code at https://github.com/expressjs/morgan/blob/master/index.js#L506-L507 would change as follows:

-  this._startAt = process.hrtime()
+  this._startAt = this[Symbol.for('request-received.startAt')] ? this[Symbol.for('request-received.startAt')] : process.hrtime()
-  this._startTime = new Date()
+  this._startTime = this[Symbol.for('request-received.startTime')] ? this[Symbol.for('request-received.startTime')] : new Date()
niftylettuce added a commit to niftylettuce/morgan that referenced this issue Jun 13, 2019
@niftylettuce
Copy link
Member Author

@niftylettuce niftylettuce commented Jun 13, 2019

As similar to expressjs/response-time#19 (comment), note that Symbol is not supported in Node v0.8 and v0.10, only v0.12+.

@niftylettuce
Copy link
Member Author

@niftylettuce niftylettuce commented Jun 13, 2019

See #201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants