{"action":"opened","issue":{"url":"https://api.github.com/repos/klein/klein.php/issues/358","repository_url":"https://api.github.com/repos/klein/klein.php","labels_url":"https://api.github.com/repos/klein/klein.php/issues/358/labels{/name}","comments_url":"https://api.github.com/repos/klein/klein.php/issues/358/comments","events_url":"https://api.github.com/repos/klein/klein.php/issues/358/events","html_url":"https://github.com/klein/klein.php/issues/358","id":206392454,"number":358,"title":"Handling 404's : What if I want to serve a full 404 document instead of a few lines of text.","user":{"login":"thinsoldier","id":373834,"avatar_url":"https://avatars.githubusercontent.com/u/373834?v=3","gravatar_id":"","url":"https://api.github.com/users/thinsoldier","html_url":"https://github.com/thinsoldier","followers_url":"https://api.github.com/users/thinsoldier/followers","following_url":"https://api.github.com/users/thinsoldier/following{/other_user}","gists_url":"https://api.github.com/users/thinsoldier/gists{/gist_id}","starred_url":"https://api.github.com/users/thinsoldier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thinsoldier/subscriptions","organizations_url":"https://api.github.com/users/thinsoldier/orgs","repos_url":"https://api.github.com/users/thinsoldier/repos","events_url":"https://api.github.com/users/thinsoldier/events{/privacy}","received_events_url":"https://api.github.com/users/thinsoldier/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-02-09T03:16:29Z","updated_at":"2017-02-09T03:16:29Z","closed_at":null,"body":"https://github.com/klein/klein.php/wiki/Handling-404's\r\n\r\nThe suggested technique in the wiki only shows how to send a few lines of text when 404 errors happen. I can't figure out how to server a fully styled document for 404. I mean I can serve a full document but then the http header changes from 404 to 200.\r\n\r\n```\r\n$klein->onHttpError(function ($code, $router) {\r\n    switch ($code) {\r\n        case 404:\r\n             // This works but causes the http header to be 200 instead of 404\r\n             $router->service()->render('app/views/404.php');\r\n             \r\n             //$router->response()->body('404 Not Found');\r\n        \t\t\r\n            break;\r\n        case 405:\r\n            $router->response()->body(\r\n                'You can\\'t do that!'\r\n            );\r\n            break;\r\n        default:\r\n            $router->response()->body(\r\n                'Oh no, a bad error happened that caused a '. $code\r\n            );\r\n    }\r\n});\r\n```"}}
{"actor":{"display_login":"thinsoldier"}}