Created
January 2, 2022 04:34
-
-
Save ikolomiets/689519a10f6f0a289a2ab2c06df710c1 to your computer and use it in GitHub Desktop.
Demo of "This function has a reified type parameter and thus can only be inlined at compilation time, not called directly" Ktor error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Serializable | |
data class Age(val value: Int) | |
@Serializable | |
data class Update<T>(val old: T, val new: T) | |
fun main() { | |
embeddedServer(Netty, port = 8080) { | |
install(ContentNegotiation) { | |
json() | |
} | |
routing { | |
update<Age>() | |
} | |
}.start(wait = true) | |
} | |
inline fun <reified T> Route.update() { | |
post("/") { | |
val update = call.receive<Update<T>>() | |
application.log.info("XXX update={}", update) | |
call.respond(HttpStatusCode.OK, "OK") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment