コード例 #1
0
ファイル: Router.php プロジェクト: jacobDaeHyung/api
 /**
  * Parse a requests accept header.
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return array
  */
 protected function parseAcceptHeader(Request $request)
 {
     if (preg_match('#application/vnd\\.' . $this->properties->getVendor() . '.(v[\\d\\.]+)\\+(\\w+)#', $request->header('accept'), $matches)) {
         return array_slice($matches, 1);
     } elseif ($this->isStrict()) {
         throw new InvalidAcceptHeaderException('Unable to match the "Accept" header for the API request.');
     }
     return [$this->properties->getVersion(), $this->properties->getFormat()];
 }
コード例 #2
0
ファイル: Dispatcher.php プロジェクト: jacobDaeHyung/api
 /**
  * Create a new internal request from an HTTP verb and URI.
  *
  * @param string       $verb
  * @param string       $uri
  * @param string|array $parameters
  *
  * @return \Dingo\Api\Http\InternalRequest
  */
 protected function createRequest($verb, $uri, $parameters)
 {
     if (!isset($this->version)) {
         $this->version = $this->properties->getVersion();
     }
     $api = $this->router->getApiGroups()->getByDomainOrVersion($this->domain, $this->version);
     if (($prefix = $api->option('prefix')) && !starts_with($uri, $prefix)) {
         $uri = sprintf('%s/%s', $prefix, $uri);
     }
     $parameters = array_merge($this->parameters, (array) $parameters);
     $request = InternalRequest::create($this->url->to($uri), $verb, $parameters, $this->cookies, $this->uploads, [], $this->content);
     if ($domain = $api->option('domain')) {
         $request->headers->set('host', $domain);
     }
     foreach ($this->headers as $header => $value) {
         $request->headers->set($header, $value);
     }
     $request->headers->set('accept', $this->buildAcceptHeader());
     return $request;
 }
コード例 #3
0
ファイル: GroupCollection.php プロジェクト: jacobDaeHyung/api
 /**
  * Get the default API route collection.
  *
  * @return \Dingo\Api\Routing\RouteCollection|null
  */
 public function getDefault()
 {
     return $this->getByVersion($this->properties->getVersion());
 }