No more manually declared routes. Use annotations directly on your methods.
@GET(value = "/articles", name = "articles.index")
@POST(value = "/articles", name = "articles.store")
@PUT(value = "/articles/:id", name = "articles.update")
@DELETE(value = "/articles/:id", name = "articles.delete")
@PATCH(value = "/articles/:id", name = "articles.patch")
@GET(value = "/articles/:id", name = "articles.show")
private Object show(Request req, Response res) {
String id = req.params(":id");
// ...
}
@GET(value = "/search", name = "search")
private Object search(Request req, Response res) {
String query = req.queryParams("q");
String page = req.queryParams("page");
// ...
}
Use the name parameter to reference routes by name instead of hardcoding paths.
@GET(value = "/articles/:id", name = "articles.show")
private Object show(Request req, Response res) {
// ...
}
<a href="">View Article</a>
<form action="" method="post">
<!-- form fields -->
</form>
String path = Route.getPath("articles.show"); // "/articles/:id"
boolean exists = Route.hasRoute("articles.show"); // true
Map<String, String> all = Route.getAllRoutes(); // all named routes