RouteDecoderModule

zio.http.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 -> Root / "user" / int(id) => Response.text("User id requested: ${id}")
 case GET -> Root / "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.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Concise view

Type members

Classlikes

abstract class RouteDecode[A](f: String => A)

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object boolean.type
object byte.type
object date.type
object double.type
object float.type
object int.type
object long.type
object short.type
object time.type
object uuid.type
object boolean extends RouteDecode[Boolean]

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
boolean.type
object byte extends RouteDecode[Byte]

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
byte.type
object date extends RouteDecode[LocalDate]

Attributes

Graph
Supertypes
class RouteDecode[LocalDate]
class Object
trait Matchable
class Any
Self type
date.type
object double extends RouteDecode[Double]

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
double.type
object float extends RouteDecode[Float]

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
float.type
object int extends RouteDecode[Int]

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
int.type
object long extends RouteDecode[Long]

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
long.type
object short extends RouteDecode[Short]

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
short.type
object time extends RouteDecode[LocalDateTime]

Attributes

Graph
Supertypes
class RouteDecode[LocalDateTime]
class Object
trait Matchable
class Any
Self type
time.type
object uuid extends RouteDecode[UUID]

Attributes

Graph
Supertypes
class RouteDecode[UUID]
class Object
trait Matchable
class Any
Self type
uuid.type