You can easily bind a route path to a controller method. Routes path are defined in the same way as in expressjs router.
Each route class has the following methods:
path- same as in expressjs.
method- one of
action- the action function the will be invoked to handle the route.
middleware- middleware function the will be invoked before the controller. If the
nextfunction is not called or called with an error, the controller won`t be created.
path can be defined with
path can be static string ,dynamic params or regex expressions
prefix to all routes in the controller can be added using
/api/v1/prefix to all routes in this controller
You can return response by using
You can also define routes using
or using discovery
you can set the route order if 2 route collide.
in the example
/test/:id will catch also
we can solve this using the
/ are ordered last
you can catch not found routes using