edit(editType: String) = Action {
implicit request =>
editType match {
case "name" =>
try {
Ok(views.html.editNamePage())
} catch {
case e: Exception =>
Ok(views.html.errorPage())
}
case "saveName" =>
try {
Ok("saveFullName")
} catch {
case e: Exception =>
Ok("0")
}
case "email" =>
try {
Ok(views.html.editEmailpage("result"))
} catch {
case e: Exception =>
Ok(views.html.errorPage())
}
case "saveEmail" =>
try {
Ok("success")
} catch {
case e: Exception =>
Ok("0")
}
case "removeEmail" =>
try {
Ok("success")
} catch {
case e: Exception =>
Ok("0")
}
}
}
ROUTE
POST /edit controllers.ControllerName.edit(editType:String)
you can use pattern matching on a controller method. by this way you can use a single root multiple times for diffrent purposes. it reduces you number of routes