Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active February 3, 2026 20:23
Show Gist options
  • Select an option

  • Save dacr/c90695117036c9f357c5a6e6ec2615d2 to your computer and use it in GitHub Desktop.

Select an option

Save dacr/c90695117036c9f357c5a6e6ec2615d2 to your computer and use it in GitHub Desktop.
lorem ipsum generator web service / published by https://github.com/dacr/code-examples-manager #befe18d5-583d-45f4-a08a-5a24707dc0df/5607f01af8c8963c9b4a184a8f9bcc071df2e838
// summary : lorem ipsum generator web service
// keywords : scala, loremipsum, webserver, akkahttp
// publish : gist
// authors : David Crosson
// license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
// id : befe18d5-583d-45f4-a08a-5a24707dc0df
// created-on : 2020-04-05T18:21:33Z
// managed-by : https://github.com/dacr/code-examples-manager
// execution : scala ammonite script (http://ammonite.io/) - run as follow 'amm scriptname.sc'
import $ivy.`fr.janalyse::lorem-ipsum-server-akkahttp:1.0.11`
import akka.http.scaladsl._
import akka.http.scaladsl.server.Directives._
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import loremipsum.server.akkahttp._
object LoremServer {
implicit val system = akka.actor.ActorSystem("MySystem")
implicit val materializer = akka.stream.ActorMaterializer()
implicit val executionContext = system.dispatcher
val routes = ServiceRoutes(ServiceDependencies.defaults).routes
Http()
.newServerAt("0.0.0.0", 8080)
.bind(routes)
.andThen{case _ => println("Ready and listening on 8080")}
def startAndWait:Unit = Await.ready(LoremServer.system.whenTerminated, Duration.Inf)
}
// Mandatory as LoremServer is asynchronous
LoremServer.startAndWait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment