Skip to content

Instantly share code, notes, and snippets.

@debasishg
Created June 18, 2013 19:59
Show Gist options
  • Select an option

  • Save debasishg/5808749 to your computer and use it in GitHub Desktop.

Select an option

Save debasishg/5808749 to your computer and use it in GitHub Desktop.
Play 2.0 router generates a documentation field returning, for each route of the application, its HTTP method (GET, PUT, etc.), its path pattern and finally the call as it was written in the conf/routes file. The router generates a Routes object which is loaded by your Play application when started, you can access it.
val routeInfo =
for {
routes <- play.api.Play.current.routes.toList
(method, pattern, call) <- routes.documentation
} yield (method, pattern, call)
println(routeInfo)
generates ..
List((GET,/,controllers.Application.index), (HEAD,/credentialValidation,com.eligotech.hnavigator.web.controllers.CredentialValidation.validateCredentials), (POST,/job,com.eligotech.hnavigator.web.controllers.JobManagement.createJob), (GET,/job/$id<[^/]+>,com.eligotech.hnavigator.web.controllers.JobManagement.getById(id:String)), (DELETE,/job/$id<[^/]+>,com.eligotech.hnavigator.web.controllers.JobManagement.deleteById(id:String)), (OPTIONS,/$path<.+>,com.eligotech.hnavigator.web.controllers.OptionHandler.options(path:String)), (OPTIONS,/job,com.eligotech.hnavigator.web.controllers.JobManagement.options(id:String = "")), (OPTIONS,/job/$id<[^/]+>,com.eligotech.hnavigator.web.controllers.JobManagement.options(id:String)), (GET,/job,com.eligotech.hnavigator.web.controllers.JobManagement.getByState(state:Option[String] ?= None)), (GET,/jobs,com.eligotech.hnavigator.web.controllers.JobManagement.getList), (GET,/file/$path<.+>,com.eligotech.hnavigator.web.controllers.FileServiceManagement.serveAction(path:String, action:String ?= "preview", chunkSize:Option[Int] ?= None, limit:Option[Int] ?= None)), (GET,/store/database,com.eligotech.hnavigator.web.controllers.StorageManagement.getDatabaseList), (GET,/store/database/$db<[^/]+>,com.eligotech.hnavigator.web.controllers.StorageManagement.getDatabaseByName(db:String)), (GET,/store/database/$db<[^/]+>/table,com.eligotech.hnavigator.web.controllers.StorageTableManagement.getTableList(db:String)), (GET,/store/database/$db<[^/]+>/table/$table<[^/]+>,com.eligotech.hnavigator.web.controllers.StorageTableManagement.getTableByDatabase(db:String, table:String)), (GET,/store/database/$db<[^/]+>/table/$table<[^/]+>/column,com.eligotech.hnavigator.web.controllers.StorageFieldManagement.getColumnList(db:String, table:String)), (GET,/store/search,com.eligotech.hnavigator.web.controllers.SchemaFilter.doSearch(query:String, scope:List[String], context:List[String], offset:Int ?= 0, limit:Option[Int] ?= None)), (GET,/statistics/database/$db<[^/]+>/table/$table<[^/]+>/column/$column<[^/]+>,com.eligotech.hnavigator.web.controllers.IndexManagement.getFieldStats(db:String, table:String, column:String)), (GET,/assets/$file<.+>,controllers.Assets.at(path:String = "/public", file:String)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment