Java has already some common annotations to declare which HTTP methods and paths are available for an API endpoint (http://docs.oracle.com/cd/E19798-01/821-1841/giepu/index.html). We could use these annotations in an controller to provide meta informations how an controller/method can be used. We could probably add an discover command which parses all controllers from the source and vendor folder and suggest how you can add them to your routing file. Probably we could also extract an description about the controller. In this way users could easily add new controllers to their application and since they must manually add the route there is no risk that malicious packages register unwanted routes. The annotations could look like:
class FooController extends ControllerAbstract
{
/**
* @GET
* @POST
* @Path('/foo/:id')
* @Consumes("application/json")
* @Produces("application/json")
*/
public function doIndex()
{
}
}
Java has already some common annotations to declare which HTTP methods and paths are available for an API endpoint (http://docs.oracle.com/cd/E19798-01/821-1841/giepu/index.html). We could use these annotations in an controller to provide meta informations how an controller/method can be used. We could probably add an discover command which parses all controllers from the source and vendor folder and suggest how you can add them to your routing file. Probably we could also extract an description about the controller. In this way users could easily add new controllers to their application and since they must manually add the route there is no risk that malicious packages register unwanted routes. The annotations could look like: