public function run() { foreach ($this->providers as $provider) { $provider->boot(); } $request = Http\Request::createFromGlobals(); $response = $this['Api\\RequestHandler']->handle($request); $response->send(); }
public function boot() { Request::setAcceptParser($this->app['Sunel\\Api\\Http\\Parser\\Accept']); }
/** * Attempt to parse the token from query * * @param \Illuminate\Http\Request $request * * @return null|string */ protected function fromQuery(Request $request) { return $request->query($this->key); }
/** * Get the URI, methods, and action from the route. * * @param mixed $route * @param \Sunel\Api\Http\Request $request * * @return array */ public function getRouteProperties($route, Request $request) { $uri = ltrim(isset($route['uri']) ? $route['uri'] : $request->getRequestUri(), '/'); $methods = isset($route['methods']) ? $route['methods'] : (array) $request->getMethod(); $action = isset($route[1]) && is_array($route[1]) ? $route[1] : $route; if ($request->getMethod() === 'GET' && !in_array('HEAD', $methods)) { $methods[] = 'HEAD'; } return [$uri, $methods, $action]; }