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

Option to yield to next middleware without setting response code #154

Open
ryanstevens opened this issue Sep 18, 2015 · 1 comment
Open

Comments

@ryanstevens
Copy link

This is more of a question at this point, but why does ecstatic set the response code in some cases before it yields control to the next middleware in the chain. So for example if estatic hits the 404 use case this status-handler#L37 sets the response code to 404 AND then calls next() if it exists.

I would prefer to pass in an option to not set the response code if another middleware will ultimately be invoked. Philosophically I would make the case if estatic yields control to another middleware it shouldn't mutate anything on the response object since it "had it's chance" so to speak.

@jfhbrook
Copy link
Owner

There's two things going on here. One is that this is a way for downstream middlewares to detect what happened inside ecstatic---without setting the status code there isn't really a good way to know why a request fell through. The other is an artifact of architecture---ecstatic has a few recursive calls, and I believe (it's been a while since I've looked at this) it branches based on req state.

Ecstatic is somewhat constrained by the fact that it's intended to be used as a middleware. That has unfortunate ramifications both pragmatic and philosophical beyond but including setting of status codes as a mechanism for custom 404/etc handling.

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

No branches or pull requests

2 participants