com-lihaoyi / cask

Cask: a Scala HTTP micro-framework. Cask makes it easy to set up a website, backend server, or REST API using Scala
https://com-lihaoyi.github.io/cask/
Other
525 stars 55 forks source link

Make `cask.QueryParams` work for JSON endpoints, and form endpoints, replace `subpath = true` with `cask.RemainingPathSegments` #109

Closed lihaoyi closed 8 months ago

lihaoyi commented 8 months ago

subpath = true as a named argument passed to the annotation runs into issues if multiple named arguments are present (see https://stackoverflow.com/questions/55032173/how-to-use-named-arguments-in-scala-user-defined-annotations), which prevents us from using named arguments to the annotation more broadly as a user-facing API.

Using typed parameters to the method def sidesteps this issue, and neatly allows us to provide the captured value to the user. This is also more in line with how we handle inputs in general: cookies, known/typed query params, unknown query params, json input, form fields, etc.