summaryrefslogtreecommitdiff
path: root/opendc-common/src/main/kotlin/org/opendc/common/utils/JavalinRunner.kt
diff options
context:
space:
mode:
authormjkwiatkowski <mati.rewa@gmail.com>2026-02-23 12:05:58 +0100
committermjkwiatkowski <mati.rewa@gmail.com>2026-02-23 12:05:58 +0100
commit4f816318b6672d40f23b22ca44cc06b77cadf961 (patch)
tree40aa2cae25fee7a92eb36d1d471534a8b53fecd0 /opendc-common/src/main/kotlin/org/opendc/common/utils/JavalinRunner.kt
parentdaad473975cc3e6eba0536d5a8fe750cf8b2fa7d (diff)
feat: added a working connection to Redis, and a scaffolding for the RESTful APIHEADmaster
Diffstat (limited to 'opendc-common/src/main/kotlin/org/opendc/common/utils/JavalinRunner.kt')
-rw-r--r--opendc-common/src/main/kotlin/org/opendc/common/utils/JavalinRunner.kt45
1 files changed, 35 insertions, 10 deletions
diff --git a/opendc-common/src/main/kotlin/org/opendc/common/utils/JavalinRunner.kt b/opendc-common/src/main/kotlin/org/opendc/common/utils/JavalinRunner.kt
index 9db7bfaf..a43e23a8 100644
--- a/opendc-common/src/main/kotlin/org/opendc/common/utils/JavalinRunner.kt
+++ b/opendc-common/src/main/kotlin/org/opendc/common/utils/JavalinRunner.kt
@@ -1,25 +1,50 @@
package org.opendc.common.utils
import io.javalin.Javalin
-import io.javalin.http.Context
import io.javalin.http.Handler
+/**
+ * Represents the digital twin monitoring server.
+ * @author Mateusz Kwiatkowski
+ * @see <a href=https://javalin.io/documentation>https://javalin.io/documentation</a>
+ */
+
public class JavalinRunner {
+ private val handshake: Handler = Handler { ctx -> ctx.status(200) }
- private val handleHello: Handler = Handler { ctx ->
- ctx.status(200)
- ctx.contentType("application/x-protobuf")
- ctx.result("Hello world")
+ private val scenario: Handler = Handler { ctx ->
}
init {
+ // Make a CRUD RESTful API
+ // Specify server config
val app = Javalin.create().start()
- app.get("/hello", handleHello)
+ // returns a list of all experiments
+ app.get("/experiment", handshake)
+
+ // returns a specific experiment
+ app.get("/experiment/:id", handshake)
+
+ // you need another endpoint for the metrics
+
+ // get the results for the metrics evaluation
+ app.get("/results/:id", handshake)
+
+ // returns all results
+ app.get("/results", handshake)
+
+ // sends a specific experiment
+ app.post("/experiment", scenario)
+
+ // changes a specific experiment
+ app.put("/experiment/:id", scenario)
+ // this should delete metrics associated with the experiment
+
+ // deletes an experiment with id
+ app.delete("/experiment/:id", scenario)
- app.exception<Exception?>(Exception::class.java, { e: Exception?, ctx: Context? ->
- e!!.printStackTrace()
- ctx!!.status(500)
- })
+ // deletes all experiments
+ app.delete("/experiment", scenario)
}
} \ No newline at end of file