Lift3, futures and resthelper

47 views
Skip to first unread message

Colin Bester

unread,
Oct 17, 2017, 10:36:29 AM10/17/17
to Lift
I realize I need to sit down, read and catch up on new features of Lift 3 but am battling due to amount of information covering range of versions.

  1. There has been tremendous work done in bringing out Lift 3 and I can understand documentation being behind (and have no problem with that) but any suggestions on where to find most up to date documentation, especially on new features?
  2. I have a future streaming response function that I use to serve an image via RestHelper and am wanting to know if there are any gotchas I am missing in implementing as below.
  3. I normally try avoid using global execution context but don't really see a way around this at present (going to kick myself later I am sure) - any recommendations?


object DocumentServer extends RestHelper {

 import scala.concurrent.ExecutionContext.Implicits.global


  def init() { ..}

 def getQRCodeFuture(deviceId: String, format:String = "jpg", size:Int = 150)(implicit ec: ExecutionContext): Future[StreamingResponse] = {}


 serve {

  case "api" :: "qrcode" :: deviceId :: Nil Get _ => {

    val size = for {

      width <- S.param("size")        

    } yield {

      try {

        width.toInt

      } catch {

        case x:java.lang.NumberFormatException => 150

      }

    }

    getQRCodeFuture(deviceId, "jpg", size.getOrElse(150))

 }

}


Antonio Salazar Cardozo

unread,
Oct 17, 2017, 1:56:23 PM10/17/17
to Lift
I believe you should be good on that example---let us know if you're seeing issues. There
may be some possible strange interactions between futures and streaming responses, but
I don't think so off the top of my head. No real thoughts on the global execution context---if
it works, it works :)

As for getting caught up on Lift 3, I tried to compile as many changes or links to additional
compendia of changes in the original announcement @ https://github.com/lift/framework/releases/tag/3.0-release .
There is also a handful of changes that went into 3.1.0: https://github.com/lift/framework/releases/tag/3.1.0-release .
In general, we'll been trying to keep release notes comprehensive and linked to their relevant
PRs moving forward.
Thanks,
Antonio

Colin Bester

unread,
Oct 17, 2017, 4:33:33 PM10/17/17
to Lift
Thanks, much appreciated.

Matt Farmer

unread,
Oct 18, 2017, 12:24:09 PM10/18/17
to Lift
I'm actually doing some of this in my REST API for the judicial-manager project I'm working on in my spare time. If you run into any issues, it may be a helpful reference! :)

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Colin Bester

unread,
Oct 18, 2017, 1:31:16 PM10/18/17
to Lift
Thanks for sharing Matt!
Reply all
Reply to author
Forward
0 new messages