The Play + Java + CRUD Activator has the following route
file, and I don't understand what ->
does in it.
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
# Home page
GET / controllers.Application.index()
# CRUD Controllers and REST API
-> / play.crud.Routes
The answer to this question lies in the app/conf/routes configuration file. Play's router translates HTTP requests into action calls.
Play Framework makes it easy to build web applications with Java & Scala. Play is based on a lightweight, stateless, web-friendly architecture. Built on Akka, Play provides predictable and minimal resource consumption (CPU, memory, threads) for highly-scalable applications.
A Router is an actor that routes incoming messages to outbound actors. The router routes the messages sent to it to its underlying actors called 'routees'.
Play Framework is an open-source web application framework which follows the model–view–controller (MVC) architectural pattern. It is written in Scala and usable from other programming languages that are compiled to JVM bytecode, e.g. Java.
In my opinion, the Play documentation for this is poor. I will explain based on a nice sample on Github.
In conf/routes
you may have:
-> /admin admin.Routes
-> /customer customer.Routes
-> /common common.Routes
then, for example, admin.Routes
, you can resolve as follows:
Look for the definition for admin
which is in Build.sbt
:
// Admin Portal
lazy val admin = project.in(file("modules/admin"))
.dependsOn(common)
You see that it's in modules/admin
. Head over to modules/admin/conf/routes
where you'll see more routes:
GET /index controllers.admin.Application.getIndex()
So, Play puts that together with the original path /admin
becoming /admin/index
. That is, if you bring up /admin/index
in the browser, controllers.admin.Application.getIndex()
will be used to serve this route.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With