/** * Based on the body, will attempt to determine a type * * @return string */ public static function getType() { // if (Verbs::getVerb() == v_get) { // return - 1; // } $body = Body::getBody(); $possibleJson = json_decode($body); if ($possibleJson) { return t_json; } Error::throwInternalException('The API does not support types other than JSON yet OR you have invalid JSON'); }
/** * This will build the request * * Basically we need to scrape very particular data out of PHP and the binaries existing memory load * This will form the data into what we consider "The Request" * * This is subject to change BUT, * The paradigm of always being able to automagically build "The Request" from memory will stay * "The Request" should magically appear from thin air here */ public function __construct() { $this->startTime = new \Cassandra\Timestamp(); $this->protocol = Protocols::getProtocol(); /* HTTP(s) */ $this->verb = Verbs::getVerb(); /* How are we sending this request? */ Body::addBody($this); /* First adaption - will add the body type and content to the object */ /* If an ID is set, use it for the request, otherwise generate a new one */ if (isset($this->body['s_id'])) { $this->id = $this->body['s_id']; } else { $this->id = uniqid(); } $this->headers = Header::getHeaderArray(); /* Get the headers, if we have them */ $this->status = s_new; /* New request */ // /* Transactions are handled in Process */ $this->isAuthenticated = Auth::isAuthenticated(); /* Lets us know if we are authenticated */ $this->endpoint = Endpoint::getEndpoint(); /* Endpoint for the request */ $exp = explode('/', $this->endpoint); $this->keyspace = strtolower($exp[0]); /* Cassandra keyspace for this request */ $this->table = strtolower(str_replace('/', '_', $this->endpoint)); /* Table from endpoint */ $this->schema = Schema::getSchemaArray($this); /* Schema map */ $this->response = new Response(); $this->session = new Session(); $this->session->start(); }