Reputation: 418
I want to catch all unkown GET operations.
My routes file looks like this:
GET / controllers.MainController.index()
#All other routes
#finally
GET /[^/]+/ controllers.MainController.fault()
The final GET definition is at the bottom on the list because of the priority given to the above get operations, otherwise all requests would be true to the /[^/]+/ condition.
The problem is that it goes to the default catch page saying 'Action not found'
How can I catch all routes?
Upvotes: 0
Views: 495
Reputation: 7466
I believe
GET /*route controllers.MainController.fault()
would work better. route
will capture the path that was received, you can pass it as an argument to your fault
method.
But, I would suggest another alternative: you can implement a GlobalSettings
object where you override the method
def onHandlerNotFound(request: RequestHeader): Future[SimpleResult]
This method will be called each time you get a request for which it was not possible to find a proper handler. You can find more information here: http://www.playframework.com/documentation/2.2.x/ScalaGlobal
Upvotes: 2