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

Override resource handlers #3

Open
desmondmorris opened this issue Mar 17, 2015 · 4 comments
Open

Override resource handlers #3

desmondmorris opened this issue Mar 17, 2015 · 4 comments

Comments

@desmondmorris
Copy link
Member

There should be a way to override the default generated handlers. You should be able to house the resource files in a directory that is discoverable or configurable.

@jfelixetcetera
Copy link
Contributor

Some sort of middleware stack might be best here. Keeping in mind that overriding might not be the goal, but extending/hooking might sometimes be more beneficial.

@desmondmorris
Copy link
Member Author

@joshuajabbour I think you are right - middleware is probably the way to go - should be trivial to implement pre/post style hooks here.

My question is, after res.end is executed, can a middleware hook be executed after?

@jfelixetcetera
Copy link
Contributor

No, res.end/res.send is the end of it all. I looked into this a bit last night, and the consensus seems to be wrapping send. This however is I think a conceptual flaw with middleware that we'll have to work around. What we really want it to have a result object that can be passed through middleware, maybe pushing that onto the response object is the only way to go...

@desmondmorris
Copy link
Member Author

Hmm maybe the default handlers become something like this?

(req, res, next ) => {

   if (typeof next === 'function') {
     return next(req, res);
   }  

   // DEFAULT HANDLER LOGIC
}

Though I think "next" is always a function, so this may be flawed.

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

No branches or pull requests

2 participants