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

fix: add named arrow function for request and response handlers #805

Merged
merged 1 commit into from
Feb 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,16 @@ module.exports = class Application extends Emitter {

if (!this.listeners('error').length) this.on('error', this.onerror);

return (req, res) => {
const handleRequest = (req, res) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathanong "named arrow function" back

res.statusCode = 404;
const ctx = this.createContext(req, res);
const onerror = err => ctx.onerror(err);
const handleResponse = () => respond(ctx);
onFinished(res, onerror);
fn(ctx).then(() => respond(ctx)).catch(onerror);
fn(ctx).then(handleResponse).catch(onerror);
};

return handleRequest;
}

/**
Expand Down