package controllers

import play.api.libs.json._
import play.api.mvc._
import models.Book._

class Application extends Controller {

  def listBooks = Action {
    Ok(Json.toJson(books))
  }

  def saveBook = Action(BodyParsers.parse.json) { request =>
    val b = request.body.validate[Book]
    b.fold(
      errors => {
        BadRequest(Json.obj("status" -> "OK", "message" -> JsError.toFlatJson(errors)))
      },
      book => {
        addBook(book)
        Ok(Json.obj("status" -> "OK"))
      }
    )
  }
}

package controllers

import play.api.libs.json._
import play.api.mvc._
import models.Book._

object Application extends Controller {

  def listBooks = Action {
    Ok(Json.toJson(books))
  }

  def saveBook = Action(BodyParsers.parse.json) { request =>
    val b = request.body.validate[Book]
    b.fold(
      errors => {
        BadRequest(Json.obj("status" -> "OK", "message" -> JsError.toFlatJson(errors)))
      },
      book => {
        addBook(book)
        Ok(Json.obj("status" -> "OK"))
      }
    )
  }
}

--- 
+++ 
@@ -4,7 +4,7 @@
 import play.api.mvc._
 import models.Book._
 
-object Application extends Controller {
+class Application extends Controller {
 
   def listBooks = Action {
     Ok(Json.toJson(books))
Make the controller a class as per Play 2.4 routing

avoids compile errors like "type Application is not a member of package
controllers", see http://stackoverflow.com/a/30544381/14955
