aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/App.kt
diff options
context:
space:
mode:
authorMarvin Borner2019-05-05 22:27:42 +0200
committerMarvin Borner2019-05-05 22:27:42 +0200
commitbd89369b508f30fc987b27cf6b34a22fbc8e5d97 (patch)
tree8bb338a1112b4dae52d9d6d2919be4ce3d9544f9 /src/main/kotlin/App.kt
parent5081b240b07f08e21ad124da8bddf0e11471792d (diff)
Added simple admin interface
Co-authored-by: LarsVomMars <lars@kroenner.eu>
Diffstat (limited to 'src/main/kotlin/App.kt')
-rw-r--r--src/main/kotlin/App.kt26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/main/kotlin/App.kt b/src/main/kotlin/App.kt
index 5370f4b..c403b5a 100644
--- a/src/main/kotlin/App.kt
+++ b/src/main/kotlin/App.kt
@@ -44,20 +44,32 @@ fun main(args: Array<String>) {
get(
"/css/*", { ctx ->
ctx.contentType("text/css")
- ctx.result(Thread.currentThread().contextClassLoader.getResourceAsStream("css/" + ctx.splat(0)))
+ try {
+ ctx.result(Thread.currentThread().contextClassLoader.getResourceAsStream("css/" + ctx.splat(0)))
+ } catch (_: Exception) {
+ ctx.status(404)
+ }
},
roles(Roles.GUEST, Roles.USER)
)
get(
"/js/*", { ctx ->
ctx.contentType("text/javascript")
- ctx.result(Thread.currentThread().contextClassLoader.getResourceAsStream("js/" + ctx.splat(0)))
+ try {
+ ctx.result(Thread.currentThread().contextClassLoader.getResourceAsStream("js/" + ctx.splat(0)))
+ } catch (_: Exception) {
+ ctx.status(404)
+ }
},
roles(Roles.GUEST, Roles.USER)
)
get(
"/fonts/*", { ctx ->
- ctx.result(Thread.currentThread().contextClassLoader.getResourceAsStream("fonts/" + ctx.splat(0)))
+ try {
+ ctx.result(Thread.currentThread().contextClassLoader.getResourceAsStream("fonts/" + ctx.splat(0)))
+ } catch (_: Exception) {
+ ctx.status(404)
+ }
},
roles(Roles.GUEST, Roles.USER)
)
@@ -99,9 +111,13 @@ fun main(args: Array<String>) {
/**
* Adds part of a new user (username) to database
- * TODO: Create post request with admin interface
*/
- get("/user/add", databaseController::indexUserRegistration, roles(Roles.ADMIN))
+ post("/user/add", databaseController::indexUserRegistration, roles(Roles.ADMIN))
+
+ /**
+ * Renders the admin interface
+ */
+ get("/admin", userHandler::renderAdmin, roles(Roles.ADMIN))
/**
* Renders the setup page (only on initial use)