Skip to content

Instantly share code, notes, and snippets.

@kobus1998
Created May 14, 2019 10:07
Show Gist options
  • Save kobus1998/2955575d4941baf546ce77b0774e18ee to your computer and use it in GitHub Desktop.
Save kobus1998/2955575d4941baf546ce77b0774e18ee to your computer and use it in GitHub Desktop.
Router design
<?php
$router->add('GET', '/user/:userId', /* All callable */, $middleware1, $middleware2, $controller);
try {
$router->execute($request);
} catch (\HttpError\Code500 $e) {
$e->viewMessage();
} catch (\HttpError\Code403 $e) {
$e->viewMessage();
} catch (\HttpError\Code401 $e) {
$e->viewMessage();
} catch (\HttpError\Code400 $e) {
$e->viewMessage();
} catch (\Exception $e) {
// general uncaught message
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment