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

Added local() to request #433

Closed
wants to merge 2 commits into from
Closed

Conversation

coopernurse
Copy link

Hi there,

express is cool. I'm writing an app that uses route chaining via next(). I didn't see an obvious way to set state on the request so that my first route handler could set a variable that I could reference in subsequent handlers.

I added a local() function on request for this. It's similar to param() but only gets/sets variables that you define.

Not sure if this is a patch more appropriate to add to Connect, but let me know what you think.

Tests included.

thank you!

-- James

@tj
Copy link
Member

tj commented Sep 20, 2010

typically you just put props like that right on req, but you will have the same potential namespacing issues

@coopernurse
Copy link
Author

ah, I see. do you see value in providing a "local" namespace for this? Could help prevent folks from accidentally clobbering reserved slots on req. If not, perhaps I'll revert this patch and simply add some notes to the express docs explaining that you should hang stuff directly off req. As a node/connect/express newb I didn't realize that was how you do it.

@tj
Copy link
Member

tj commented Sep 20, 2010

I would rather them be on req, as long as people are careful with their naming

@coopernurse
Copy link
Author

Ok. I'll close out this pull request and take a look at the express docs and perhaps add an example for this. thank you.

@tj
Copy link
Member

tj commented Sep 20, 2010

sounds good thanks :)

This pull request was closed.
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

Successfully merging this pull request may close these issues.

None yet

2 participants