tipsy
07/19/2017, 7:34 PMtipsy
07/19/2017, 7:34 PMorangy
<http://foo.com/?q=1&q=2&q=3>
orangy
orangy
List<String>?
which is null if any param is missing, or param values in order, so you can do this?
val (name, category, value) = mapQueryParams("n", "c", "v") ?: throw InvalidUrlParametersException()
tipsy
07/19/2017, 7:37 PMbecause which one?having multiple values for a query param is fine.. i'm not a big fan, but a lot of people do that
tipsy
07/19/2017, 7:37 PMtipsy
07/19/2017, 7:54 PMorangy
tipsy
07/19/2017, 7:57 PMorangy
tipsy
07/19/2017, 8:14 PMorangy
tipsy
07/19/2017, 8:22 PMfun mapQueryParams(vararg keys: String): List<String>? = try {
keys.map { servletRequest.getParameter(it) }.requireNoNulls().toList()
} catch (e: IllegalArgumentException) {
null
}
orangy
orangy
servletRequest
be a receiver for a function?tipsy
07/19/2017, 8:33 PMservletRequest
is a javax.servlet.http.HttpServletRequest
, if that makes any differences4nchez
07/20/2017, 10:52 AM/?x=&y=
and /?x&y
? (i.e. you can have null
and empty string values)s4nchez
07/20/2017, 10:56 AMorangy
null
is there if you didn’t specify a parameters4nchez
07/20/2017, 10:58 AM/?x
from /
(by allowing to get the list of parameters, even if they contain null
value). Again, probably useful in very few cases.orangy
/?x
will get empty string for x
, and /
will get null for xemuz
07/20/2017, 12:33 PMorangy
emuz
07/20/2017, 12:37 PMdanneu
07/22/2017, 3:07 PMdanneu
07/22/2017, 3:09 PM/?q=&q
would prob be ['', '']
though i could see an api like req.query.listOf("q")
vs req.query.get("q")
where the latter always returns the last valuedudleyf
07/27/2017, 9:08 PMrkeazor
07/28/2017, 1:37 PMdave
07/28/2017, 4:25 PM