Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Util for Play Cookies
package util
import play.api.mvc.{Cookie, Cookies}
/**
* Created with IntelliJ IDEA.
* User: arthur
* Date: 17/11/13
* Time: 22:26
* To change this template use File | Settings | File Templates.
*/
object CookiesUtil {
implicit class CookiesImprovements(val c: Cookies) {
import util.StringUtils._
def getAsIntOrElse(key: String, default: Int): Int = c match {
case x: Cookies => x.get(key) match {
case cookieOpt: Some[Cookie] => cookieOpt.get match {
case cookie: Cookie => cookie.value.toIntOrElse(default)
case _ => default
}
case _ => default
}
case _ => default
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.