playframework-2.3

How is path interpreted when using SIRD in Play framework


The following example is from Play's documentation

To use the routing DSL in conjunction with a regular Play project that uses a routes file and controllers, extend the SimpleRouter:

package api

import javax.inject.Inject

import play.api.mvc._
import play.api.routing.Router.Routes
import play.api.routing.SimpleRouter
import play.api.routing.sird._

class ApiRouter @Inject()(controller: ApiController)
  extends SimpleRouter
{
  override def routes: Routes = {
    case GET(p"/") => controller.index
  }
}

Add the following line to conf/routes:

->      /api                        api.ApiRouter

Question - In the above example As /api already maps to ApiRouter, does GET(p"/") resolve to somedomain.com/api/ or somedomain.com/


Solution

  • It will resolve to somedomain.com/api/, that is the main idea of the SIRD - it allows you to modularize routers.