Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>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. <em>Please note however, as this is an undocumented feature, may mean it is unintended, and therefore may break in future versions of play.</em></p> <p>You are able to achieve what you want using the following line in your routes file.</p> <pre><code>%{ if (play.mode.isDev()) }% </code></pre> <p>I created a test application with a couple of actions</p> <pre><code>public class Application extends Controller { public static void index() { render(); } public static void noDev() { renderText("NoDev"); } public static void noProd() { renderText("NoProd"); } } </code></pre> <p>I then added the following to my routes file</p> <pre><code># Home page GET / Application.index # Ignore favicon requests GET /favicon.ico 404 # Map static resources from the /app/public folder to the /public path GET /public/ staticDir:public %{ if (play.mode.isDev()) }% GET /route1 Application.noDev GET /route2 Application.noDev GET /route3 Application.noDev * /{controller}/{action} {controller}.{action} %{ if (play.mode.isProd()) }% GET /route4 Application.noProd GET /route5 Application.noProd GET /route6 Application.noProd * /{controller}/{action} {controller}.{action} </code></pre> <p>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.</p> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload