hello, how can i convert this spring webhook ``` ...
# server
a
hello, how can i convert this spring webhook
Copy code
data class WR(status: String)
    @RestController
    @RequestMapping("/webhook")
    class WebhookController {

        @PostMapping
        fun postMessage(@RequestBody json: String) : WebhookResponse {
            return WR("ok")
        }
    }
to ktor , i am little bit confused
a
data class WR(status: String)
fun Routing.webhookController() {
route("/webhook") {
post {
val body = call.recieveOrNull<Map<String,String>>()
val json = body?.get("json") as String
val response = WR("ok")
call.respond(HttpStatusCode.OK, response)
}
}
}
👍 1
a
Thanks Ok, let me try
@Ali Albaali recieveOrNull is not working
a
oh it's
receiveOrNull
you can also use just
receive<Map<String,String>>()
a
@Ali Albaali where to run it or like this
Copy code
fun main(){
  embeddedServer(Netty, port = 8080){
      routing {
          webhookController()
     }.start(wait = true)
}
a
Yep you can run it like that
a
@Ali Albaali finally it got to work, thanks for your effort 😀😊
👋 1
a
You're welcome
👍 1