public function getRoute(RequestReader $request) { $url = (string) $request->getUrl(); $method = $request->getHttpMethod(); if (substr($url, 0, 1) === '@') { $key = substr($url, 1); return $this->getRouteByKey($key); } foreach ($this->routes as $route) { if ($route->match($request)) { return $route; } } throw new RouteException("Route Not Found"); }
public function match(RequestReader $req) { return in_array($req->getHttpMethod(), $this->getMethods()); }
public function getFoo(RequestReader $req, PathParam $id, GetParam $type = null) { return array('method' => $req->getHttpMethod(), 'id' => $id->get(), 'type' => $type == null ? null : $type->get()); }