If you do not like the routes file, you can also describe your routes programmatically by adding annotations to your controllers. This has the advantage of not having any additional config
file, but also poses the problem of your URLs being dispersed in your code.
You can find the source code of this example in the examples/chapter2/annotation-controller
directory.
Go to your project and install the router module via conf/dependencies.yml
:
require: - play - play -> router head
Then run playdeps
and the router module should be installed in the modules/
directory of your application. Change your controller like this:
@StaticRoutes({ @ServeStatic(value="/public/", directory="public") }) public class Application extends Controller { @Any(value="/", priority=100) public static void index() { forbidden("Reserved for administrator"); } @Put(value="/", priority=2, accept="application/json") ...