Closed OndrejSpanel closed 8 months ago
This is covered in the section on Variable Routes I think
You can bind variables to endpoints by declaring them as parameters: these are either taken from a path-segment matcher of the same name (e.g.
postId
above), or from query-parameters of the same name (e.g.param
above). You can make param take a: String
to match?param=hello
, an: Int
for?param=123
aSeq[T]
(as above) for repeated params such as?param=hello¶m=world
, or: Option[T]
for cases where the?param=hello
is optional.
Added more docs in https://github.com/com-lihaoyi/cask/pull/107
This took me a while to find:
or:
This way the query parameter is optional. It may seem intuitive, but I have tried several different ways before trying this (e.g. just making param: Option[String]. or providing overloads of def hello).