RouteDecoderModule

Instead of using just String as path params, using the RouteDecoderModule we can extract and converted params into a specific type also.

Http.collect[Request] {
 case GET -> !! / "user" / int(id) => Response.text("User id requested: ${id}")
 case GET -> !! / "user" / name    => Response.text("User name requested: ${name}")
}

If the request looks like GET /user/100 then it would match the first case. This is because internally the id param can be decoded into an Int. If a request of the form GET /user/zio is made, in that case the second case is matched.

class Object
trait Matchable
class Any

Type members

Classlikes

abstract class RouteDecode[A](f: String => A)
object boolean extends RouteDecode[Boolean]
object byte extends RouteDecode[Byte]
object date extends RouteDecode[LocalDate]
object double extends RouteDecode[Double]
object float extends RouteDecode[Float]
object int extends RouteDecode[Int]
object long extends RouteDecode[Long]
object short extends RouteDecode[Short]
object time extends RouteDecode[LocalDateTime]
object uuid extends RouteDecode[UUID]