public function testResolveBasedOnUriPath() { $stack = new Stack(); $stack->employ(array('pattern' => '/foo*', 'class' => 'Server\\TestStack', 'config' => array('body' => 'foo'))); $stack->employ(array('pattern' => '/bar*', 'class' => 'Server\\TestStack', 'config' => array('body' => 'bar'))); $req = new Request('GET', '/foo'); $app = $stack->resolve($req); $res = $app->call($req); $this->assertEquals('foo', $res->body); }
public function call(Request $req = null, Error $err = null) { $this->d('Module.call(' . ($req ? '`' . $req->method . ' ' . $this->config->get('uri', $req->uri) . '`' : 'NULL') . ')'); switch ($this->state) { case static::STATE_IDLE: if (!$req) { $req = $this->getCurrentRequest(); } if ($app = $this->resolve($req)) { return $app->call($req, $err); } return $this->getProcessedResponse($req, $err); case static::STATE_LOOP: return $this->getProcessedResponse($req, $err); } return parent::call($req, $err); }