Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Scala]: Cask framework added #7862

Merged
merged 3 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions scala/cask/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project/project
project/target
target/
.bloop/
.metals/
.vscode/
project/metals.sbt
15 changes: 15 additions & 0 deletions scala/cask/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
val CaskVersion = "0.9.4"

name := "server"

scalaVersion := "3.5.1"

run / fork := true

lazy val root = (project in file("."))
.settings(
libraryDependencies ++= Seq(
"com.lihaoyi" %% "cask" % CaskVersion
)
)
.enablePlugins(JavaAppPackaging)
3 changes: 3 additions & 0 deletions scala/cask/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
framework:
website: com-lihaoyi.github.io/cask/
version: 0.9.4
1 change: 1 addition & 0 deletions scala/cask/project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.9.9
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this file could dropped.

the sbt version is driven by dockerfile, actually it is 1.10.2

1 change: 1 addition & 0 deletions scala/cask/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "latest.integration")
26 changes: 26 additions & 0 deletions scala/cask/src/main/scala/Main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
case class MinimalRoutes()(implicit cc: castor.Context, log: cask.Logger) extends cask.Routes{

@cask.get("/")
def hello() = {
""
}

@cask.post("/user")
def postUser(request: cask.Request) = {
""
}

@cask.get("/user/:name") // variable path segment, e.g. HOST/user/lihaoyi
def getUser(name: String) = {
name
}

initialize()
}


object MinimalRoutesMain extends cask.Main {
override val port = 3000

val allRoutes = Seq(MinimalRoutes())
}
Loading