mirror of
https://github.com/FoggedLens/deflock.git
synced 2026-07-09 21:58:39 +02:00
initial commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package me.deflock.shotgun
|
||||
|
||||
import org.apache.pekko
|
||||
import pekko.actor.typed.ActorSystem
|
||||
import pekko.actor.typed.scaladsl.Behaviors
|
||||
import pekko.http.scaladsl.Http
|
||||
import pekko.http.scaladsl.model._
|
||||
import pekko.http.scaladsl.server.Directives._
|
||||
|
||||
import scala.concurrent.ExecutionContextExecutor
|
||||
import scala.io.StdIn
|
||||
|
||||
object ShotgunServer {
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
|
||||
implicit val system: ActorSystem[Any] = ActorSystem(Behaviors.empty, "my-system")
|
||||
implicit val executionContext: ExecutionContextExecutor = system.executionContext
|
||||
|
||||
val route =
|
||||
path("oauth2" / "callback") {
|
||||
get {
|
||||
parameters(Symbol("code").?) { (code) =>
|
||||
complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<h1>Say hello to Pekko HTTP</h1><p><b>Code: " + code.getOrElse("None") + "</b></p>"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val bindingFuture = Http().newServerAt("localhost", 8080).bind(route)
|
||||
|
||||
println(s"Server now online. Please navigate to http://localhost:8080\nPress RETURN to stop...")
|
||||
StdIn.readLine() // let it run until user presses return
|
||||
bindingFuture
|
||||
.flatMap(_.unbind()) // trigger unbinding from the port
|
||||
.onComplete(_ => system.terminate()) // and shutdown when done
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package example
|
||||
|
||||
import org.scalatest._
|
||||
|
||||
class HelloSpec extends FlatSpec with Matchers {
|
||||
"The Hello object" should "say hello" in {
|
||||
Hello.greeting shouldEqual "hello"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user