dimitar_
01/15/2022, 12:03 PMLocations
I have a problem configuring a simple POST endpoint. I have the following code:
@Location("/v1/login")
class Login
post<Login> {
...
}
But I get 404s. If I change it to get<Login> {…} everything is ok.
Can’t seem to find any examples using post and LocationsDominaezzz
01/15/2022, 12:54 PMdimitar_
01/15/2022, 1:31 PMAleksei Tirman [JB]
01/15/2022, 2:37 PMpost from the io.ktor.locations package.dimitar_
01/15/2022, 2:42 PMAleksei Tirman [JB]
01/15/2022, 2:48 PMimport io.ktor.application.*
import io.ktor.locations.*
import io.ktor.response.*
import io.ktor.routing.routing
import io.ktor.server.engine.*
import io.ktor.server.netty.*
@OptIn(KtorExperimentalLocationsAPI::class)
fun main(args: Array<String>) {
embeddedServer(Netty, port = 8080) {
install(Locations)
routing {
post<Login> {
call.respondText { "post" }
}
}
}.start()
}
@Location("/v1/login")
class Logindimitar_
01/15/2022, 3:14 PMDominaezzz
01/15/2022, 3:16 PMdimitar_
01/15/2022, 3:19 PM.<http://locations.post|locations.post> import, for some reason