This commit is contained in:
parent
3acd5ba0e3
commit
cceb6e69e2
@ -4,7 +4,9 @@ import com.google.gson.GsonBuilder
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import io.ktor.application.*
|
||||
import io.ktor.config.*
|
||||
import io.ktor.http.content.*
|
||||
import io.ktor.request.*
|
||||
import io.ktor.response.*
|
||||
import io.ktor.routing.*
|
||||
import io.ktor.util.*
|
||||
import kotlin.text.toCharArray
|
||||
@ -41,10 +43,22 @@ fun Application.module(testing: Boolean = false) {
|
||||
}
|
||||
|
||||
routing {
|
||||
get("/benchmark") {
|
||||
val requestBody : String = call.receiveText()
|
||||
val msgObj: MessageObject = gson.fromJson(requestBody,MessageObject::class.java)
|
||||
get("/sample"){
|
||||
call.respond("0")
|
||||
}
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user