Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7000109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:37:44+00:00 2026-05-27T20:37:44+00:00

Is it possible to run some controllers and routes only in test mode? I

  • 0

Is it possible to run some controllers and routes only in test mode?

I need to mock some response when clicking by link. I would create controller and routs that would be available only when I run play test.

Is it possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:37:45+00:00Added an answer on May 27, 2026 at 8:37 pm

    As Mike has indicated, the code from my Blog indeed shows you how to configure your route file, so that only certain routes are available in Dev or Prod mode. So…

    %{ if (play.mode.isDev()) { }%
    GET     /route4                                 Application.noProd
    GET     /route5                                 Application.noProd
    GET     /route6                                 Application.noProd
    %{ } }%
    

    However, this will indeed prevent these routes from working in Prod mode, but they will not exclude the controller from being accessed. The reason for this, is that more than likely you will have the following at the bottom of your routes file

    *       /{controller}/{action}                  {controller}.{action}
    

    This means that I can access the Application.noProd action using the catch all route, which would be the following URL

    /application/noprod
    

    So. If you want to hide your routes and your controllers, you have a few options.

    1. You could remove the catch-all route, so that there is no entry other than the specific routes you have set up. This does mean that you need to specify all your routes for all actions in your routes file.

    2. Secondly, you could check for play.mode.isDev() in your actions, and call badRequest() to prevent access. This would make this much more visible, but may be an unacceptable overhead in coding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to write and run with Visual Studio 2008 some unit test
Is it possible to make svn run some command before every commit? I have
Using only MySQL , I'm seeing if it's possible run an insert statement ONLY
I noticed its possible to run SQL scripts with Oracle's SQLPlus by providing only
is it possible to run some program in background for iphone even if your
I have a need to run some automation tasks in a web browser control
I need to extract data from a DB2 table, run some processing on each
Is it possible to run some code when an assembly is loaded, without doing
I want to run some code on startup to pre-cache some stuff, and would
Is it possible to run some PHP pages at example.com AND also run a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.