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 f4c9829b087188893e7eba301f99a1ef89e3b441..2c0aa0cef0aa271230c322ec9262d53d6d088398 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 56233b647c0e98a08fbd3d157a8da0fa24880a99..00d9ddcb9b7cfcc8776276eb3406701bc5560a5b 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() } }