{"action":"closed","issue":{"url":"https://api.github.com/repos/mikecao/flight/issues/218","labels_url":"https://api.github.com/repos/mikecao/flight/issues/218/labels{/name}","comments_url":"https://api.github.com/repos/mikecao/flight/issues/218/comments","events_url":"https://api.github.com/repos/mikecao/flight/issues/218/events","html_url":"https://github.com/mikecao/flight/issues/218","id":115786825,"number":218,"title":"这种Route运行Class方式是正确的吗？","user":{"login":"ztd","id":2644777,"avatar_url":"https://avatars.githubusercontent.com/u/2644777?v=3","gravatar_id":"","url":"https://api.github.com/users/ztd","html_url":"https://github.com/ztd","followers_url":"https://api.github.com/users/ztd/followers","following_url":"https://api.github.com/users/ztd/following{/other_user}","gists_url":"https://api.github.com/users/ztd/gists{/gist_id}","starred_url":"https://api.github.com/users/ztd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ztd/subscriptions","organizations_url":"https://api.github.com/users/ztd/orgs","repos_url":"https://api.github.com/users/ztd/repos","events_url":"https://api.github.com/users/ztd/events{/privacy}","received_events_url":"https://api.github.com/users/ztd/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mikecao/flight/labels/Question","name":"Question","color":"bfe5bf"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-09T04:00:25Z","updated_at":"2016-01-04T05:08:58Z","closed_at":"2016-01-04T05:08:58Z","body":"<?php\r\nrequire 'flight/Flight.php';\r\n\r\nFlight::map('action', function(){\r\n    $vals = func_get_args();\r\n    $action = explode('@', end($vals)->pass[0]);\r\n    $class = $action[0];\r\n    $method = isset($action[1])?$action[1]:'index';\r\n    $params = end($vals)->params;\r\n    $obj = new $class();\r\n    call_user_func_array(array($obj, $method), $params);\r\n});\r\nFlight::before('route', function(&$params, &$output){\r\n    $action = $params[1];\r\n    $param = isset($params[2])?$params[2]:array();\r\n    $params[1] = array('Flight', 'action');\r\n    $params[2] = array($action, $param);\r\n});\r\n\r\nFlight::register('db', '\\app\\libs\\medoo', array(array('database_type'=>'sqlite', 'database_file'=>'flight.db')));\r\nFlight::register('auth', 'app\\libs\\Auth');\r\n\r\nFlight::route('/', '\\app\\home');\r\nFlight::route('/login', '\\app\\home@login');\r\nFlight::route('/logout', '\\app\\home@logout');\r\nFlight::route('/blog/@id:[0-9]+', '\\app\\blog@view', array('id'=>$id));\r\nFlight::route('/admin', '\\app\\admin');\r\n\r\nFlight::start();"}}