make it more fancy
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2020-10-21 01:52:03 +02:00
parent 3acd5ba0e3
commit cceb6e69e2
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047

View File

@ -4,7 +4,9 @@ import com.google.gson.GsonBuilder
import com.typesafe.config.ConfigFactory import com.typesafe.config.ConfigFactory
import io.ktor.application.* import io.ktor.application.*
import io.ktor.config.* import io.ktor.config.*
import io.ktor.http.content.*
import io.ktor.request.* import io.ktor.request.*
import io.ktor.response.*
import io.ktor.routing.* import io.ktor.routing.*
import io.ktor.util.* import io.ktor.util.*
import kotlin.text.toCharArray import kotlin.text.toCharArray
@ -41,10 +43,22 @@ fun Application.module(testing: Boolean = false) {
} }
routing { routing {
get("/benchmark") { get("/sample"){
val requestBody : String = call.receiveText() call.respond("0")
val msgObj: MessageObject = gson.fromJson(requestBody,MessageObject::class.java) }
mqttClient.publish("command/${msgObj.device_id}", message) post("/benchmark") {
val multipart = call.receiveMultipart()
multipart.forEachPart { part ->
when (part) {
is PartData.FormItem -> {
if (part.name == "description") {
val msgObj: MessageObject = gson.fromJson(part.value,MessageObject::class.java)
mqttClient.publish("command/${msgObj.device_id}", message)
}
}
}
part.dispose()
}
} }
} }
} }