mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 15:05:50 +01:00
Improve session handling.
This commit is contained in:
@@ -54,10 +54,19 @@ object Implicits {
|
||||
}
|
||||
|
||||
implicit class RichSession(session: HttpSession){
|
||||
|
||||
def putAndGet[T](key: String, value: T): T = {
|
||||
session.setAttribute(key, value)
|
||||
value
|
||||
}
|
||||
|
||||
def getAndRemove[T](key: String): Option[T] = {
|
||||
val value = session.getAttribute(key).asInstanceOf[T]
|
||||
if(value == null){
|
||||
session.removeAttribute(key)
|
||||
}
|
||||
Option(value)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user