v3.0.0
Breaking Change
The getRoutes()
method got renamed to get_routes()
to keep the naming conventions consistent
Changelog
Improved method chaining so that it now supports multiple chain sets of request with a single call without having to end the chain and they can also share global data (prefix(es) and middleware(s))
Example:
$routes
->prefix("/test")
->middleware([ 'decode_token' ])
->get("/t1", function () { }) // route would be: /test/t1
->get("/t2", function () { }) // route would be: /test/t2
->get("/t3", function () { }) // route would be: /test/t3
->save(false) // by passing the false argument here, we keep all the previous shared data from the chain (previous prefix(es) and middlewares)
->prefix("/test2")
->middleware([ "verify_token" ])
->get("/t4", function () { }) // route would be: /test/test2/t4
->get("/t5", function () { }) // route would be: /test/test2/t5
->get("/t6", function () { }) // route would be: /test/test2/t6
->save() // by not passing the false argument here, we are removing all shared data from the previous chains (previous prefix(es) and middlewares)
->prefix("/test3")
->middleware([ "verify_token" ])
->get("/t7", function () { }) // route would be: /test3/t7
->get("/t8", function () { }) // route would be: /test3/t8
->get("/t9", function () { }) // route would be: /test3/t9
->add(); //using save or add at the end makes the chaining stop and allows for other independent routes to be added