Play framework routes

user1275645

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?

vptheron

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

play framework - bind enum in routes

From Dev

Play Framework, REST, Routes, and Controllers

From Dev

Scala backticks in Play Framework Routes

From Dev

Domain routes in Play Framework 2.3

From Dev

Play Framework Error in Routes file

From Dev

Non-capturing wildcards in Play Framework routes

From Dev

Using POST routes parameters in Play Framework

From Dev

Iterating all Play Framework routes in Test

From Dev

split routes in multiple files for play framework 2.2

From Dev

Long dynamic routes in play framework 2

From Dev

Play Framework @routes.Assets.at Compilation Error

From Dev

Play framework - call controller in routes with Class parameter

From Dev

Play framework routes, and scala predef values

From Dev

Play Framework 2.3.4 routes redirection to subproject

From Dev

Non-capturing wildcards in Play Framework routes

From Dev

Using POST routes parameters in Play Framework

From Dev

Play framework - call controller in routes with Class parameter

From Dev

How to "rewrite" urls or routes with Play Framework 2

From Dev

Play Framework 2.3.4 routes redirection to subproject

From Dev

Play framework 2 : How to pass object between routes, views, and controller?

From Dev

Syntax highlighting for scala.html and routes files in IntelliJ / Play framework

From Dev

Play Framework. Routes. Error: "not enough arguments for method at..."

From Dev

Play Framework: split routes in multiple files without sub projects

From Dev

How to use imports and implicits in Play Framework's routes file?

From Dev

how to define optional path parameters in Play Framework routes

From Dev

Play Framework & IntelliJ - Cannot resolve symbol index/routes

From Dev

Play Framework: split routes in multiple files without sub projects

From Dev

Play Framework finding the wrong routes file when compiling

From Dev

Reversing Scala Play Routes

Related Related

  1. 1

    play framework - bind enum in routes

  2. 2

    Play Framework, REST, Routes, and Controllers

  3. 3

    Scala backticks in Play Framework Routes

  4. 4

    Domain routes in Play Framework 2.3

  5. 5

    Play Framework Error in Routes file

  6. 6

    Non-capturing wildcards in Play Framework routes

  7. 7

    Using POST routes parameters in Play Framework

  8. 8

    Iterating all Play Framework routes in Test

  9. 9

    split routes in multiple files for play framework 2.2

  10. 10

    Long dynamic routes in play framework 2

  11. 11

    Play Framework @routes.Assets.at Compilation Error

  12. 12

    Play framework - call controller in routes with Class parameter

  13. 13

    Play framework routes, and scala predef values

  14. 14

    Play Framework 2.3.4 routes redirection to subproject

  15. 15

    Non-capturing wildcards in Play Framework routes

  16. 16

    Using POST routes parameters in Play Framework

  17. 17

    Play framework - call controller in routes with Class parameter

  18. 18

    How to "rewrite" urls or routes with Play Framework 2

  19. 19

    Play Framework 2.3.4 routes redirection to subproject

  20. 20

    Play framework 2 : How to pass object between routes, views, and controller?

  21. 21

    Syntax highlighting for scala.html and routes files in IntelliJ / Play framework

  22. 22

    Play Framework. Routes. Error: "not enough arguments for method at..."

  23. 23

    Play Framework: split routes in multiple files without sub projects

  24. 24

    How to use imports and implicits in Play Framework's routes file?

  25. 25

    how to define optional path parameters in Play Framework routes

  26. 26

    Play Framework & IntelliJ - Cannot resolve symbol index/routes

  27. 27

    Play Framework: split routes in multiple files without sub projects

  28. 28

    Play Framework finding the wrong routes file when compiling

  29. 29

    Reversing Scala Play Routes

HotTag

Archive