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 | 41 |
1 files changed, 12 insertions, 29 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 a43e23a8..23baac27 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,50 +1,33 @@ package org.opendc.common.utils import io.javalin.Javalin -import io.javalin.http.Handler +import org.opendc.common.annotations.Endpoint +import org.opendc.common.api.AssetsController /** * Represents the digital twin monitoring server. + * For endpoint documentation see `AssetsController`. * @author Mateusz Kwiatkowski * @see <a href=https://javalin.io/documentation>https://javalin.io/documentation</a> + * @see org.opendc.common.api.AssetsController */ +@OptIn(Endpoint::class) public class JavalinRunner { - private val handshake: Handler = Handler { ctx -> ctx.status(200) } - - private val scenario: Handler = Handler { ctx -> - } + private val assetsController : AssetsController = AssetsController() init { - // Make a CRUD RESTful API - // Specify server config val app = Javalin.create().start() + app.get("/assets", assetsController.getAssets()) - // 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) + app.get("/assets/{id}", assetsController.getAssetsId()) - // sends a specific experiment - app.post("/experiment", scenario) + app.post("/assets", assetsController.postAsset()) - // changes a specific experiment - app.put("/experiment/:id", scenario) - // this should delete metrics associated with the experiment + app.put("/assets/{id}", assetsController.putAssetId()) - // deletes an experiment with id - app.delete("/experiment/:id", scenario) + app.delete("/assets/{id}", assetsController.deleteAssetId()) - // deletes all experiments - app.delete("/experiment", scenario) + app.delete("/assets", assetsController.deleteAsset()) } }
\ No newline at end of file |
