Hello everybody! I have a question as a newby. I’d...
# ktor
d
Hello everybody! I have a question as a newby. I’d like to implement on ktor 2 endpoint: one authenticated and one not, but with the same endpoint Something like authenticate(“jwt”) { get(“hello”) { call.respond(“Authenticated”) } } get(“hello”) { call.respond(“Public”) } The above is of course not working. Is there a way to achieve this?
l
you can do
Copy code
authenticate("jwt", optional = true) {
...
}
Per docs,
Copy code
* optional=true:
 *   - No credentials: route handler will be executed with a null [Principal]
 *   - Bad credentials: Unauthorized
 *   - Good credentials: route handler will be execute
👆 3
d
Thank you very much!