commit d27d961bc38cbbfb81f526a06554c1c6c20f3c3c
parent 4859be076b0780921fdfe8c8f63320797ddbe3cf
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date: Tue, 8 Oct 2019 15:35:17 +0200
calling the ktor client
Diffstat:
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/nexus/build.gradle b/nexus/build.gradle
@@ -4,12 +4,12 @@ application {
dependencies {
implementation project(":sandbox")
+ compile "io.ktor:ktor-client-apache:1.2.4"
}
jar {
manifest {
attributes "Main-Class": "tech.libeufin.nexus.MainKt"
-
}
from {
diff --git a/nexus/src/main/kotlin/DB.kt b/nexus/src/main/kotlin/DB.kt
@@ -0,0 +1,5 @@
+package tech.libeufin.nexus
+
+import org.jetbrains.exposed.dao.*
+import org.jetbrains.exposed.sql.*
+import org.jetbrains.exposed.sql.transactions.transaction
+\ No newline at end of file
diff --git a/nexus/src/main/kotlin/Main.kt b/nexus/src/main/kotlin/Main.kt
@@ -20,19 +20,21 @@
package tech.libeufin.nexus
import io.ktor.application.call
-import io.ktor.application.install
-import io.ktor.features.CallLogging
-import io.ktor.features.ContentNegotiation
-import io.ktor.gson.gson
+import io.ktor.client.*
+import io.ktor.client.features.ServerResponseException
+import io.ktor.client.request.get
import io.ktor.response.respondText
import io.ktor.routing.get
import io.ktor.routing.post
import io.ktor.routing.routing
import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
-import java.text.DateFormat
+import tech.libeufin.sandbox.getLogger
fun main() {
+
+ val logger = getLogger()
+
val server = embeddedServer(Netty, port = 5001) {
routing {
@@ -42,11 +44,20 @@ fun main() {
}
post("/nexus") {
+ val client = HttpClient()
+ val content = try {
+ client.get<ByteArray>(
+ "https://ebicstest1.libeufin.tech/"
+ )
+ } catch (e: ServerResponseException) {
+ logger.info("Request ended bad.")
+ }
call.respondText("Not implemented!\n")
return@post
}
}
}
+
server.start(wait = true)
}