diff options
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.kt | 45 |
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 |
