Kohkimakimoto\Worker\HttpServer\HttpController::index PHP Method

index() public method

public index ( $parameters )
    public function index($parameters)
    {
        $pretty = $this->getQueryParameter("pretty", false);
        if ($pretty) {
            $pretty = true;
        }
        $jobs = $this->worker->job->getJobs();
        $jobsList = [];
        foreach ($jobs as $v) {
            $jobsList[] = $v->toArray();
        }
        $contents = ["name" => $this->worker->config->getName(), "number_of_jobs" => count($jobs), "jobs" => $jobsList];
        if ($pretty) {
            $output = json_encode($contents, JSON_PRETTY_PRINT);
        } else {
            $output = json_encode($contents);
        }
        $this->response->writeHead(200, array('Content-Type' => 'application/json; charset=utf-8'));
        $this->response->end($output);
        $this->server->outputAccessLog($this->request, 200);
    }