コード例 #1
0
ファイル: Body.php プロジェクト: kris-nova/API
 /**
  * Will return the body of the request
  */
 public static function getBody()
 {
     switch (Verbs::getVerb()) {
         case v_get:
             if (empty($_GET)) {
                 return '{}';
             }
             return json_encode($_GET);
         case v_post:
             return file_get_contents('php://input');
         case v_put:
             return file_get_contents('php://input');
         case v_delete:
             return file_get_contents('php://input');
     }
 }
コード例 #2
0
ファイル: Request.php プロジェクト: kris-nova/API
 /**
  * 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();
 }