Partish
Partish

Reputation: 47

Why reverse routing has been added in play framework?

Why reverse routing has been added in play framework since we could have directly called any action method from any other action method?

Upvotes: 1

Views: 369

Answers (1)

Andriy Kuba
Andriy Kuba

Reputation: 8263

Reverse routing simplifies support of URL endpoints.

Assume we have a route file

POST   /login/action          controllers.LoginController.login

For example, you create a login page and you need to put an action on the form:

<form action="/login/action" method="post">
...
</form>

Reverse routing allow you to put here just a method call

<form action="@routes.LoginController.login" method="post">
...
</form>

In the second case, you will not need to edit the template file if you change the login URL in the routes file.

One more thing - in the first case, you can forget to change URL in a template and then, you will end up with a nasty issue when you build is correct, but you have links that end ups with 404.

Upvotes: 5

Related Questions