Skip to content

Instantly share code, notes, and snippets.

@joshuakfarrar
Last active March 3, 2025 05:04
Show Gist options
  • Save joshuakfarrar/563bff634c525a9224cf7ac3965a409f to your computer and use it in GitHub Desktop.
Save joshuakfarrar/563bff634c525a9224cf7ac3965a409f to your computer and use it in GitHub Desktop.
// this is our possible base64-encoded byte array — serialized — flash cookie
val flashCookie: Option[String] = request.headers
.get[Cookie]
.flatMap(_.values.find(_.name == "flash"))
.map(_.content)
// aquí tienes, voilà
flashCookie.map(_.decode).sequence.fold(
_ => BadRequest("failed to deserialize cookie, this is very bad"),
cookie => Ok(renderPage(cookie)) // or do whatever we want with our freshly baked Option[Map[String, String]]
) // F[Response[F]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment