Is there a way in Play to annotate routes to inform that a certain section/group routes is only available in dev or prod mode
相关问题
- Backbone.js PushState routes .htaccess only workin
- PlayFramework: how to transform each element of a
- Laravel - Implicit route model binding with soft d
- Could not import the newly generated play framewor
- Play Framework Unicode symbols in HTTP Header
相关文章
- Testing request with CSRF Token in Play framework
- How to map an abstract collection with jpa?
- play2 framework my template is not seen. : package
- How does @Inject in Scala work
- Should I use RouteParameter or UrlParameter for an
- play framework 2.0 - unexpected exception - Key No
- Error integration fingerprint U.are.U SDK with jav
- Custom bridge table in playframework ebean
For play framework version 2.x:
routes
file lets sayprod.routes
in the root of your application (same directoy of originalroutes
file), this file contains only the routes that you want for production..conf
file likeprod.conf
insideconf
folder.for the play framework 2.4 and newer :
Or without new
.conf
file pass parameter:-Dplay.http.router=prod.Routes
And if older than 2.4 then :
And when you run the production run it with
-Dconfig.file=prod.conf
Well, this is not documented, so I am not sure if this is intentionally possible or not, but I have found a way to make this work. Please note however, as this is an undocumented feature, may mean it is unintended, and therefore may break in future versions of play.
You are able to achieve what you want using the following line in your routes file.
I created a test application with a couple of actions
I then added the following to my routes file
So, you can see that using a simple if statement, it will execute the next group of routes only in that mode. The if statement will end when the next if statement is found.
If in Dev mode you try to access route4, you will not be able to access it, and you will see the RouteNotFound page showing that the available routes are those that you have defined for Dev only.