Get all active routes / paths in running Play app

Is there a standard way to get all possible (excluding wildcards, of course) routes / paths acting in a game application?

I can do it with

Play.current.routes.map( _.documentation.map(_._2))

      

which gives me all the routes available, but it looks a little hacky to me.

+3


source to share


1 answer


Just to clarify, what I'm doing is this (exactly what you did):

  val myroutes = Play.current.routes map (routes => routes.documentation) getOrElse (Nil)
  myroutes foreach { r =>
    println("%-10s %-50s %s".format(r._1, r._2, r._3))
  }

      

And I also get:



GET        /                                                  controllers.Application.index
GET        /apis                                              controllers.Application.apis
GET        /docs                                              controllers.Application.docs
GET        /sampleapi/status/$id<[^/]+>                       controllers.SampleAPI.status(id:String)
GET        /city/$id<[^/]+>                                   controllers.CityAPI.findById(id:Long)
GET        /city1/$id<[^/]+>                                  controllers.CityAPI.findById1(id:Long)
GET        /apps/authorize/                                   controllers.Apps.authorize
POST       /apps/send_auth/                                   controllers.Apps.send_auth
GET        /clients/                                          controllers.Clients.list
GET        /client/new                                        controllers.Clients.create
POST       /client/add                                        controllers.Clients.add
POST       /client/update                                     controllers.Clients.update
GET        /client/edit/$id<[^/]+>                            controllers.Clients.edit(id:String)
PUT        /client/                                           controllers.Clients.update
GET        /client/$id<[^/]+>                                 controllers.Clients.get(id:String)
DELETE     /client/$id<[^/]+>                                 controllers.Clients.delete(id:String)
GET        /login                                             controllers.Auth.login
POST       /authenticate                                      controllers.Auth.authenticate
GET        /logout                                            controllers.Auth.logout
POST       /oauth2/access_token                               controllers.OAuth2Controller.accessToken
GET        /webjars/$file<.+>                                 controllers.WebJarAssets.at(file:String)
GET        /assets/$file<.+>                                  controllers.Assets.at(path:String = "/public", file:String)

      

This also includes the webjar and assets path, so you can filter them.

+2


source







All Articles