From a1876df44a7c2bf62f15db6f354a81308058c041 Mon Sep 17 00:00:00 2001 From: Torsten Grote <t@grobox.de> Date: Wed, 25 Aug 2021 11:01:43 +0200 Subject: [PATCH] Add routing for API draft --- .../mailbox/core/server/Routing.kt | 70 ++++++++++++++++++- .../mailbox/core/server/WebServerManager.kt | 4 +- 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/mailbox-core/src/main/java/org/briarproject/mailbox/core/server/Routing.kt b/mailbox-core/src/main/java/org/briarproject/mailbox/core/server/Routing.kt index f4c9829b..2c0aa0ce 100644 --- a/mailbox-core/src/main/java/org/briarproject/mailbox/core/server/Routing.kt +++ b/mailbox-core/src/main/java/org/briarproject/mailbox/core/server/Routing.kt @@ -4,11 +4,75 @@ import io.ktor.application.Application import io.ktor.application.call import io.ktor.http.ContentType import io.ktor.response.respondText +import io.ktor.routing.delete import io.ktor.routing.get +import io.ktor.routing.post +import io.ktor.routing.put +import io.ktor.routing.route import io.ktor.routing.routing -internal fun Application.configureRouting() = routing { - get("/") { - call.respondText("Hello world!", ContentType.Text.Plain) +internal const val V = "/" // TODO set to "/v1" for release + +internal fun Application.configureBasicApi() = routing { + + route("$V/") { + get { + call.respondText("Hello world!", ContentType.Text.Plain) + } + delete { + TODO("Not yet implemented") + } + } + + put("$V/setup") { + TODO("Not yet implemented") + } + +} + +internal fun Application.configureContactApi() = routing { + + route("$V/contacts") { + put("{contactId}") { + TODO("Not yet implemented. contactId: ${call.parameters["contactId"]}") + } + delete("{contactId}") { + TODO("Not yet implemented. contactId: ${call.parameters["contactId"]}") + } + get { + TODO("Not yet implemented") + } } + +} + +internal fun Application.configureFilesApi() = routing { + + route("$V/files/{mailboxId}") { + post { + TODO("Not yet implemented. mailboxId: ${call.parameters["mailboxId"]}") + } + get { + TODO("Not yet implemented. mailboxId: ${call.parameters["mailboxId"]}") + } + route("/{fileId}") { + get { + TODO( + "Not yet implemented. mailboxId: ${call.parameters["mailboxId"]}" + + "fileId: ${call.parameters["fileId"]}" + ) + } + delete { + TODO( + "Not yet implemented. mailboxId: ${call.parameters["mailboxId"]}" + + "fileId: ${call.parameters["fileId"]}" + ) + } + } + } + + get("$V/mailboxes") { + TODO("Not yet implemented") + } + } diff --git a/mailbox-core/src/main/java/org/briarproject/mailbox/core/server/WebServerManager.kt b/mailbox-core/src/main/java/org/briarproject/mailbox/core/server/WebServerManager.kt index 56233b64..00d9ddcb 100644 --- a/mailbox-core/src/main/java/org/briarproject/mailbox/core/server/WebServerManager.kt +++ b/mailbox-core/src/main/java/org/briarproject/mailbox/core/server/WebServerManager.kt @@ -20,7 +20,9 @@ class WebServerManager @Inject constructor() : Service { private val server by lazy { embeddedServer(Netty, PORT, watchPaths = emptyList()) { install(CallLogging) - configureRouting() + configureBasicApi() + configureContactApi() + configureFilesApi() } } -- GitLab