feat(14): enabling public resource serving
this time with "staticResources" for files in 'main/resources' which should be copied and put onto classpath by the scala compilation, yay
This commit is contained in:
parent
ec5cac0680
commit
83c75ad3a9
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
|
@ -1,15 +1,21 @@
|
|||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html class="no-js" lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
||||
<title>Initial flie</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="32x32"
|
||||
href="../public/images/favicon-32x32.png"
|
||||
th:href="'public/images/favicon-32x32.png'"
|
||||
/>
|
||||
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||
<!-- Place favicon.ico in the root directory -->
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<!--[if lt IE 8]>
|
||||
|
@ -21,10 +27,7 @@
|
|||
<![endif]-->
|
||||
<main>
|
||||
<h1>Hello!</h1>
|
||||
<p th:text="${myVar}" >
|
||||
with static text
|
||||
</p>
|
||||
<p th:text="${myVar}">with static text</p>
|
||||
</main>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -26,8 +26,7 @@ object Main {
|
|||
server.main(Array.empty)
|
||||
}
|
||||
|
||||
def main(args: Array[String]): Unit =
|
||||
{
|
||||
def main(args: Array[String]): Unit = {
|
||||
println(s"got args : $args")
|
||||
ParserForMethods(this).runOrExit(args)
|
||||
}
|
||||
|
@ -43,11 +42,12 @@ object Main {
|
|||
templateEngine.setTemplateResolver(templateResolver)
|
||||
|
||||
@cask.get("/")
|
||||
def index() = {
|
||||
def index(req: cask.Request) = {
|
||||
val context = new Context()
|
||||
println(s"getting request for ${req.remainingPathSegments}")
|
||||
context.setVariable(
|
||||
"myVar",
|
||||
"Hello, from Scala world"
|
||||
"Hello, from Scala world!"
|
||||
)
|
||||
val result = templateEngine.process("index", context)
|
||||
cask.Response(
|
||||
|
@ -56,11 +56,11 @@ object Main {
|
|||
)
|
||||
}
|
||||
|
||||
@cask.staticFiles("/dist")
|
||||
def distFiles() = "dist"
|
||||
@cask.staticFiles("/public")
|
||||
def publicFiles() = "public"
|
||||
|
||||
@cask.staticResources("/public")
|
||||
def publicFiles(req: cask.Request) = {
|
||||
println(s"getting request for ${req.remainingPathSegments}")
|
||||
"public"
|
||||
}
|
||||
initialize()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue