Search code examples
playframeworkurl-routingplayframework-2.1

Play framework production reverse routing


I am trying to set up my Play project so that some routes that are for development purposes only do not show up in production but I am having difficulty with the reverse routing.

Here are my route files, simplified:

routes (development)

GET /         controllers.Application.index()
GET /bar      controllers.Foo.bar()

production.routes

GET /         controllers.Application.index()

In home.scala.html, I have something like this:

@if(play.Play.application().configuration().getString("application.mode") != "production") {
    <a href="@routes.Foo.bar">This link does not show up in production</a>
}

When running the project in production mode, the file won't compile because it can't find the route:

value Foo is not a member of object controllers.routes

Any ideas on how to deal with this issue?


Solution

  • You have to have the same routes in production, the routes file is compliled, use a check in the controller if you don't want someone access at that method in your production mode.