Exemplo n.º 1
0
 /**
  * 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()];
 }
Exemplo n.º 2
0
 /**
  * Build the "Accept" header.
  *
  * @return string
  */
 protected function buildAcceptHeader()
 {
     return sprintf('application/vnd.%s.%s+%s', $this->properties->getVendor(), $this->version, $this->properties->getFormat());
 }
Exemplo n.º 3
0
 /**
  * Get the default API route collection.
  *
  * @return \Dingo\Api\Routing\RouteCollection|null
  */
 public function getDefault()
 {
     return $this->getByVersion($this->properties->getVersion());
 }