This application has one route which will match GET requests starting with
/hello/ and will forward the matched {name} into the callback function as
$name.

The callback function should return a
Response
object. If it returns a string, it will implicitly be converted into a Response.

Handling exceptions

It is possible that route callbacks throw an exception. By default, Cicada will
in this case return a HTTP 500 response (Internal Server Error). However, it
is possible to add exception handlers which will intercept specific exceptions
and return an appropriate response.

For example, if you want to catch a custom NotImplementedException and return a
custom error message:

The callback function passed to $app->exception() must have a single argument
and that argument must have a class type hint which denotes the exception class
which it will handle.

It's possible to specify multiple exception handlers and they will be tried in
order in which they were specified:

$app->exception(function (SomeException$ex) {returnnewResponse("Arrrghhhhh", Response::HTTP_INTERNAL_SERVER_ERROR);});$app->exception(function (OtherException$ex) {returnnewResponse("FFFFUUUUUUU...", Response::HTTP_INTERNAL_SERVER_ERROR);});// If all else fails, this will catch any exceptions$app->exception(function (Exception$ex) {$msg="Something went wrong. The incident has been logged and our code monkeys are on it.";returnnewResponse($msg, Response::HTTP_INTERNAL_SERVER_ERROR);});