Hi. Anyone can help me to understand how "param" b...
# ktor
q
Hi. Anyone can help me to understand how "param" builder works?
Copy code
fun main(args: Array<String>) {
    val server = embeddedServer(Netty, 9995) {
        install(DefaultHeaders)
        install(Compression)
        install(CallLogging)

        routing {
            route("test") {
                param("error") {
                    handle {
                        call.respondText { "error" }
                    }
                }

                get {
                    call.respondText { "test" }
                }
            }
        }
    }

    server.start()
}
If I understand correctly, then when I'm going to http://localhost:9995/test?error=123 I should get "error", but I'm getting "test".
d
Try this instead:
Copy code
fun main(args: Array<String>) {
    val server = embeddedServer(Netty, 8080) {
        install(DefaultHeaders)
        install(Compression)
        install(CallLogging)

        routing {
            route(“test”) {
                method(HttpMethod.Get) {
                    param(“error”) {
                        handle {
                            call.respondText { “error” }
                        }
                    }
                    handle {
                        call.respondText { “test” }
                    }
                }
            }
        }
    }

    server.start()
}
o
This is not exactly the same, because it will respond to get/post/put/…, not just
get
@qweryt could you please file an issue on GitHub? Slack will be lost…
d
👍 2
q
Ok, thanks, this solution will work for me.