Api.php 826 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace Thrift\Service;
  3. use Dever;
  4. $project = Dever::project('thrift');
  5. include $project['path'] . 'gen-php/DeverApi/ApiService.php';
  6. class Api implements \DeverApi\ApiServiceIf
  7. {
  8. public function get($api, $param = '')
  9. {
  10. $api = trim($api, '/');
  11. if (defined('DEVER_API_FILTER')) {
  12. $api = str_replace(DEVER_API_FILTER, '', $api);
  13. }
  14. $param = json_decode($param, true);
  15. array_unshift($param, $api);
  16. $result = call_user_func_array(array('Dever', 'load'), $param);
  17. #$result = Dever::load($api, $param);
  18. return Dever::out($result, array(), true);
  19. }
  20. public function start($process = 10)
  21. {
  22. $port = (isset($_ENV['ATOMPORT']) && $_ENV['ATOMPORT']) ? $_ENV['ATOMPORT'] : 8081;
  23. $server = new Server('socket', '0.0.0.0', $port, $process);
  24. $server->start('\DeverApi\ApiServiceProcessor', $this);
  25. }
  26. }