Let's write a simple HTTP service that return the Hello world! text for any request.

import lol.http._  

We need to have an ExecutionContext context in the scope. It will be used to execute the user code. We can use the default Scala global one.

import scala.concurrent.ExecutionContext.Implicits.global object HelloWorld { def main(args: Array[String]): Unit = {  

Here we start an HTTP server on the port 8888. We pass a (Request) => Future[Response] function to handle the requests.

Server.listen(8888) { req =>  

For each request, we just return a synchronous 200 OK response, with a text/plain content.

Ok("Hello world!") } println("Listening on http://localhost:8888...") } }