Created
January 18, 2012 20:24
-
-
Save casualjim/1635323 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait CookieSupport extends Handler { | |
self: ScalatraKernel => | |
import CookieSupport._ | |
private val _cookieOptions = new DynamicVariable[CookieOptions](null) | |
implicit def cookieOptions: CookieOptions = _cookieOptions.value | |
private val _cookies = new DynamicVariable[SweetCookies](null) | |
def cookies = _cookies.value | |
abstract override def handle(req: HttpServletRequest, res: HttpServletResponse) { | |
_cookies.withValue(new SweetCookies(req.cookies, res)) { | |
_cookieOptions.withValue(CookieOptions(path = req.getContextPath)) { | |
super.handle(req, res) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment