org.scalatra.SessionSupport.scala Maven / Gradle / Ivy
package org.scalatra
import org.scalatra.ServletCompat.http.{ HttpServletRequest, HttpSession }
import org.scalatra.servlet.ServletApiImplicits
/**
* This trait provides session support for stateful applications.
*/
trait SessionSupport { self: ServletApiImplicits =>
/**
* The current session. Creates a session if none exists.
*/
implicit def session(implicit request: HttpServletRequest): HttpSession = request.getSession
def session(key: String)(implicit request: HttpServletRequest): Any = session(request)(key)
/**
* The current session. If none exists, None is returned.
*/
def sessionOption(implicit request: HttpServletRequest): Option[HttpSession] = Option(request.getSession(false))
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy