Last active
April 2, 2023 10:11
-
-
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/f34a390d78e5649a597f4385f247e25281967d6c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// summary : lorem ipsum generator web service | |
// keywords : scala, loremipsum, webserver, akkahttp | |
// publish : gist | |
// authors : David Crosson | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// 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