Skip to content

Instantly share code, notes, and snippets.

@srp
Last active January 2, 2017 19:28
Show Gist options
  • Save srp/6d2d6b2b810d09596e497092ec2a9a8a to your computer and use it in GitHub Desktop.
Save srp/6d2d6b2b810d09596e497092ec2a9a8a to your computer and use it in GitHub Desktop.
def login(dbConn: DbConnection, req Reuqest): Try[Response] =
req.body match {
case Failure(err) =>
Failure(err)
case Success(reqJsonStr) =>
json.parse(reqJsonStr) match {
case Failure(err) =>
Failure(err)
case Success(reqJson) =>
validateAndDecode[LoginRequest](reqJson) match {
case Failure(err) =>
Failure(err)
case Success(loginReq) =>
dbConn.findUser(loginReq.username) match {
...
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment