vincent.brule
06/22/2018, 8:35 AMe5l
06/22/2018, 8:42 AMexpires
field of Cookie
classvincent.brule
06/22/2018, 9:02 AMe5l
06/22/2018, 9:55 AMvincent.brule
06/22/2018, 9:58 AMe5l
06/22/2018, 10:00 AMheader expires
? The server doesn't store custom client headers as a state.vincent.brule
06/22/2018, 10:02 AMe5l
06/22/2018, 10:03 AMvincent.brule
06/22/2018, 10:04 AMcy
06/22/2018, 10:08 AMvincent.brule
06/22/2018, 10:09 AMcy
06/22/2018, 10:10 AMcookie<UserSession>(cookieName) {
cookie.duration = Duration.ofHours(1)
}
cy
06/22/2018, 10:10 AMe5l
06/22/2018, 10:10 AMvincent.brule
06/22/2018, 10:15 AMvincent.brule
06/22/2018, 10:15 AMe5l
06/22/2018, 10:18 AMe5l
06/22/2018, 10:19 AMvincent.brule
06/22/2018, 10:19 AMvincent.brule
06/22/2018, 10:20 AMe5l
06/22/2018, 10:21 AMvincent.brule
06/22/2018, 10:23 AMDeactivated User
06/22/2018, 10:29 AMvincent.brule
06/22/2018, 10:31 AMDeactivated User
06/22/2018, 10:37 AMif (System.currentTimeMillis() > mysession.validUntil) redirect(...)
vincent.brule
06/22/2018, 10:39 AMDeactivated User
06/22/2018, 10:45 AMcall.respondRedirect
do not finish the function. So if you do it like a guard, you will have to return the function. For example:
get("/") {
if (cond) return@get call.respondRedirect("/invalid")
}
I guess that you can also simulate redirection from exception that do other frameworks with StatusPages
(so you can call a redirect in subfunctions or guard clauses without worrying about propagating the return to prevent the next code to be executed). For example:
fun Application.main() {
install(StatusPages) {
exception<HttpRedirectException> { e ->
call.respondRedirect(e.location, permanent = e.permanent)
}
}
routing {
get("/") {
if (true) redirect("/invalid")
}
}
}
class HttpRedirectException(val location: String, val permanent: Boolean = false) : RuntimeException()
fun redirect(location: String, permanent: Boolean = false): Nothing = throw HttpRedirectException(location, permanent)
Deactivated User
06/22/2018, 10:54 AMvincent.brule
06/22/2018, 11:06 AM