val userIdRegex = "user_id_(\d+)".r
val routes = Routes:
case GET() -> Path("pricing", userIdRegex(userId)) =>
Response.withBody(s"userId = ${userId}")
Note that the userId
is bound as a String
.
You could further match on it, for example:
val routes = Routes:
case GET() -> Path("pricing", userIdRegex(param[Int](userId))) =>
would extract userId
as an Int
.