remove route listing in playframework

80 views Asked by At

Playframework displays a whole list of all available routes if you call a wrong route. that looks like that:

enter image description here

Is there a way to deactivate this listing?

Thanks in advance.

2

There are 2 answers

0
Andriy Kuba On BEST ANSWER

It does this only in the development mode, it's for easy debugging.

In the production mode, the list would be empty.

0
vkt On

Play provides the default error handling mechanism

You can override the onClientError

   override def onClientError(request: RequestHeader, statusCode: Int, message: String): Future[Result] =
    statusCode match {

      case NOT_FOUND =>
        Future.successful {
          NotFound(Json.obj("error" -> s"Resource  ${request.uri} is invalid"))//or whatever error message you want.
        }
    }