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

router: a simple way to extract params from a query #45

Closed
zandaq opened this issue Jun 27, 2010 · 5 comments
Closed

router: a simple way to extract params from a query #45

zandaq opened this issue Jun 27, 2010 · 5 comments

Comments

@zandaq
Copy link

zandaq commented Jun 27, 2010

Hi,
Using router middleware, I can only extract params from a query string by parsing req:
app.get('/search', function(req, res){
var q = require('url').parse(req.url, true)['query']['q'];
res.simpleBody('200', q);
});
is it normal? I think it would be pretty good to add functionality making this process easier.
And also a method to check is it ajax request or not.
Thanks.

@tj
Copy link
Member

tj commented Jun 27, 2010

Those are typically things a higher level framework built in connect would provide. Closing for now

@bentomas
Copy link

So are things like res.simpleBody() and res.redirect(). I think Connect is right now sitting sort of in the middle. I personally agree that Connect shouldn't try and be a higher level framework, to make it as flexible as possible (especially considering I am rewriting my framework to sit on top of Connect). I just think it needs to choose a direction. I think req and res should not be extended.

@tj
Copy link
Member

tj commented Jun 28, 2010

I can agree with that. res.simpleBody() is used a bit internally but it does not have to be. redirect and similar could easily be in a contrib repo, but I guess you could say the same about flash too. tough call. I think these are nice pieces to optionally allow for framework builders, but they should be optional at least. We could add a query string parser middleware but I think that will have many use cases, express for example has param() which checks GET (querystring), POST, and route related vars, but lots of other frameworks will do it completely differently

@weepy
Copy link

weepy commented Jun 30, 2010

I think 'we' need to start having another folder or repo of cool middlewares that aren't core, but still very useful - this params middleware would fit right in there.

@tj
Copy link
Member

tj commented Jun 30, 2010

yeah i agree. Even if its just a wiki page or something. Managing them all under one repo is a bit annoying

This issue 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

No branches or pull requests

4 participants