import concurrent.Future
import play.api.GlobalSettings
import play.api.Mode
import play.api.Play
import play.api.mvc.RequestHeader
import play.api.mvc.Results.NotFound
import play.api.mvc.SimpleResult

object Global extends GlobalSettings {
  override def onHandlerNotFound(request: RequestHeader): Future[SimpleResult] = {
    Play.maybeApplication.filter(_.mode == Mode.Prod).map { _ =>
      Future.successful(NotFound)
    } getOrElse {
      super.onHandlerNotFound(request)
    }
  }
}

Return 404 Not Found status code without body when a handler is not found.
Return 404 Not Found status code without body when a handler is not found.

The default onHandlerNotFound method returns an error page in HTML. This is
unnecesary because the clients of Beyond framework check only the status code.
Changed to return only the status code if a handler is not found. This change
is in effect only in production mode.
