Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Jan 4, 2024
1 parent 299cc43 commit d251252
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions docs/pages/1 - Cask: a Scala HTTP micro-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,23 @@ $$$minimalApplication2
You can split up your routes into separate `cask.Routes` objects as makes sense
and pass them all into `cask.Main`.
## Variable Routes & Query Params
## Variable Routes
$$$variableRoutes
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` below).
You can bind path segments to endpoint parameters by declaring them as parameters. these are
either:
* A parameter of the same name as the variable path segment of the same name as you
(e.g. `postId` above),
* A parameter of type `segments: cask.RemainingPathSegments`, if you want to allow
the endpoint to handle arbitrary sub-paths of the given path
## Query Params
$$$queryParams
You can make your route
take
You can bind query parameters to your endpoint method via parameters of the form:
* `param: String` to match `?param=hello`
* `param: Int` for `?param=123`. Other valid types include `Boolean`, `Byte`, `Short`, `Long`,
Expand All @@ -157,8 +162,7 @@ take
zero values
* `params: cask.QueryParams` if you want your route to be able to handle arbitrary
query params without needing to list them out as separate arguments
* `segments: cask.RemainingPathSegments` if you want to allow the endpoint to handle
arbitrary sub-paths of the given path
* `request: cask.Request` which provides lower level access to the things that the HTTP
request provides
Expand Down

0 comments on commit d251252

Please sign in to comment.