object PfExample { val Path = """/users/(.*)""".re // pretty non-sensical in real life def handleRequest: PartialFunction[Response] = { case Path(theUserId) => { // do heaps of stuff // create response } } }