Search code examples
scalaliftimplicit-conversionimplicit

LiftWeb Rest explanation


http://simply.liftweb.net/index-5.4.html describes the LiftWeb REST.

What bothers me is that I can't exactly understand. For example,
case "count" :: Nil JsonGet _

I suspect that there is and implicit conventions from List to some another object, and I've found Get method that seems to accept List and Req type, but how it getting together? Please, help.


Solution

  • There actually is no implicit conversion going on here at all - JsonGet is an instance of TestGet, which provides an unapply method that returns an Option[(List[String], Req)]. Scala allows calling unapply as an infix method, so that construct is sugar for:

    case JsonGet("cout" :: Nil, _) => // the second argument is the Req instance