Using futures with unfiltered responses

124 views Asked by At

I am trying use the Scala Unfiltered framework. One of the main benefits of Scala is the async nature which makes use of futures. However, I am unable to get these to work when creating async web request/responses.

I have the following minimal Main.scala in order to illustrate my issue:

import unfiltered.filter._
import unfiltered.request._
import unfiltered.response._
import scala.concurrent.ExecutionContext.Implicits.global

import scala.concurrent.Await
import scala.concurrent.Future
import scala.concurrent.duration.DurationInt


class HelloWorldApp extends Plan {
    def intent = {
        case GET(Path("/")) => Future {
            PlainTextContent ~> ResponseString( "Ok" )
        }
    }
}

object Server {
    def main(args: Array[String]) {
        unfiltered.jetty.Http.local(8080).filter(new HelloWorldApp).run
    }
}

There must be a specific way of getting async requests working, but I'm not seeing how.

0

There are 0 answers