diff options
author | Marvin Borner | 2019-05-01 15:33:42 +0200 |
---|---|---|
committer | Marvin Borner | 2019-05-01 15:33:42 +0200 |
commit | 8549c68cfcf4caabb696152f36facc074129ebcf (patch) | |
tree | 35281a88f1894cf3b96c938373a249548bfe5e04 /src/main/kotlin/App.kt | |
parent | a3c10541f945068265d93ae83753dda0ac361164 (diff) |
Added deployment features and functionalityv0.1-BETA
Co-authored-by: LarsVomMars <lars@kroenner.eu>
Diffstat (limited to 'src/main/kotlin/App.kt')
-rw-r--r-- | src/main/kotlin/App.kt | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/main/kotlin/App.kt b/src/main/kotlin/App.kt index 49cc553..1aa150b 100644 --- a/src/main/kotlin/App.kt +++ b/src/main/kotlin/App.kt @@ -9,8 +9,6 @@ import io.javalin.rendering.* import io.javalin.rendering.template.TemplateUtil.model import io.javalin.security.* import io.javalin.security.SecurityUtil.roles -import io.javalin.staticfiles.* -import java.io.* import java.net.* import java.util.logging.* @@ -22,7 +20,6 @@ private val log = Logger.getLogger("App.kt") fun main() { val app = Javalin.create().apply { - enableStaticFiles("${File(".").absolutePath}/src/main/resources/", Location.EXTERNAL) port(7000) accessManager { handler, ctx, permittedRoles -> roleManager(handler, ctx, permittedRoles) } }.start() @@ -44,6 +41,30 @@ fun main() { } /** + * Renders the static resources (important for deployed jar files) + */ + get( + "/css/*", { ctx -> + ctx.contentType("text/css") + ctx.result(Thread.currentThread().contextClassLoader.getResourceAsStream("css/" + ctx.splat(0))) + }, + roles(Roles.GUEST) + ) + get( + "/js/*", { ctx -> + ctx.contentType("text/js") + ctx.result(Thread.currentThread().contextClassLoader.getResourceAsStream("js/" + ctx.splat(0))) + }, + roles(Roles.GUEST) + ) + get( + "/fonts/*", { ctx -> + ctx.result(Thread.currentThread().contextClassLoader.getResourceAsStream("fonts/" + ctx.splat(0))) + }, + roles(Roles.GUEST) + ) + + /** * Main page */ get( |