/** * Support for RESTFul GET-requests. * Only supports very BASIC REST requests, for more functionality please use * the JSON-RPC 2 interface. * * @param string $pathToResource RESTFul path to resource * * @return string $json a JSON encoded response ready for sending to client */ public function handleRESTGetRequest($pathToResource) { if (!is_string($pathToResource)) { return $this->resp(null, 0, -32099, 'IR'); } $resourceInfo = explode('/', $pathToResource); $type = $resourceInfo[0]; try { if (count($resourceInfo) < 2) { return $this->resp(RedBean_Facade::findAndExport($type)); } else { $id = (int) $resourceInfo[1]; return $this->resp(RedBean_Facade::load($type, $id)->export(), $id); } } catch (Exception $e) { return $this->resp(null, 0, -32099); } }
/** * Support for RESTFul GET-requests. * Only supports very BASIC REST requests, for more functionality please use * the JSON-RPC 2 interface. * * @param string $pathToResource RESTFul path to resource * * @return string $json a JSON encoded response ready for sending to client */ public function handleRESTGetRequest($pathToResource) { if (!is_string($pathToResource)) { return $this->resp(NULL, 0, self::C_JSONRPC2_SPECIFIED_ERROR, 'IR'); } $resourceInfo = explode('/', $pathToResource); $type = $resourceInfo[0]; try { if (count($resourceInfo) < 2) { return $this->resp(RedBean_Facade::findAndExport($type)); } else { $id = (int) $resourceInfo[1]; return $this->resp(RedBean_Facade::load($type, $id)->export(), $id); } } catch (Exception $exception) { return $this->resp(NULL, 0, self::C_JSONRPC2_SPECIFIED_ERROR); } }