Add HomeController and initial application setup with routing

This commit is contained in:
2025-10-10 11:50:10 +02:00
parent 96b48d77a0
commit d822d11acc
13 changed files with 17 additions and 8 deletions

View File

@@ -28,10 +28,11 @@ lazy val commonSettings = Seq(
lazy val knockoutwhist = project.in(file("knockoutwhist"))
.settings(
commonSettings
commonSettings,
mainClass := Some("de.knockoutwhist.KnockOutWhist")
)
lazy val knockoutwhistWeb = project.in(file("knockoutwhist-web"))
lazy val knockoutwhistweb = project.in(file("knockoutwhistweb"))
.enablePlugins(PlayScala)
.dependsOn(knockoutwhist % "compile->compile;test->test")
.settings(
@@ -40,7 +41,7 @@ lazy val knockoutwhistWeb = project.in(file("knockoutwhist-web"))
)
lazy val root = (project in file("."))
.aggregate(knockoutwhist, knockoutwhistWeb)
.aggregate(knockoutwhist, knockoutwhistweb)
.settings(
name := "KnockOutWhistRoot"
name := "KnockOutWhistWeb"
)

View File

@@ -1 +0,0 @@
/home/janis/Workspaces/IntelliJ/knockoutwhist

View File

@@ -12,6 +12,8 @@ import de.knockoutwhist.KnockOutWhist
@Singleton
class HomeController @Inject()(val controllerComponents: ControllerComponents) extends BaseController {
private var initial = false
/**
* Create an Action to render an HTML page.
*
@@ -19,7 +21,14 @@ class HomeController @Inject()(val controllerComponents: ControllerComponents) e
* will be called when the application receives a `GET` request with
* a path of `/`.
*/
def index() = Action { implicit request: Request[AnyContent] =>
Ok(views.html.main.render("KnockoutWhist", views.html.index.render()))
def index() = {
if (!initial) {
initial = true
KnockOutWhist.main(new Array[String](_length = 0))
}
Action { implicit request: Request[AnyContent] => {
Ok(views.html.main.render("KnockoutWhist", views.html.index.apply()))
}
}
}
}
}

View File

Before

Width:  |  Height:  |  Size: 687 B

After

Width:  |  Height:  |  Size: 687 B