Accessing query string parameters


#1

Cookies can be read using the following syntax: req.http.Cookie:user_id.

Is there anything similar for query string parameters (e.g. req.url.qs:user_id)?
So far I’ve been extracting values with a regex, but it would be great to have a helper like the one above.


#2

Agreed - this would be really useful!

The existing URL parameter functions are good (removing, whitelisting etc) - but having a function to get a given parameter value would be great.


#3

I’ll be the first to admit that it’s nowhere near as nice, but it’s closer:

set req.http.value-of-foo = subfield(req.url.qs, "foo", "&");

See here for more on this.


#4

Thanks, Justin! Wasn’t aware of the subfield function.

What does the third argument of the subfield function do? Is it a separator char?


#5

Correct. That specifies the separator.