Skip to content

Instantly share code, notes, and snippets.

@divarvel
Created January 16, 2012 16:56
Show Gist options
  • Save divarvel/1621772 to your computer and use it in GitHub Desktop.
Save divarvel/1621772 to your computer and use it in GitHub Desktop.
Mongo DB ObjectId request matching
object Oid {
def unapply(s: String): Option[ObjectId] = {
if(ObjectId.isValid(s)) Some(new ObjectId(s))
else None
}
}
def intent = {
case req @ Path(Seg("users" :: Oid(id) :: Nil)) => {
// Fun stuff here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment