Exemplo n.º 1
0
 public function testResponseCodeOverridesRegEx()
 {
     $urls = ['/url/ok' => '(good)'];
     $request = static::mockRequest(501, 'good');
     $guzzle = m::mock('Guzzle\\Http\\ClientInterface');
     $guzzle->shouldReceive('get')->with('/url/ok')->andReturn($request);
     $pinger = new Pinger($urls, '', $guzzle);
     $res = $pinger->interrogateUrls();
     $this->assertSame(['/url/ok' => ['status' => 501, 'result' => PingResult::STATUS_PROBLEM]], $res);
 }
Exemplo n.º 2
0
 public static function routes()
 {
     $route = '_status';
     Router::add($route, new Route($route, function ($request) {
         // ignore this transaction
         Transaction::ignore();
         // load a config
         $conf = Config::load('newrelic-ping');
         // ping the urls
         $pinger = new Pinger($conf['urls'], $conf['base_host']);
         $res = $pinger->ping();
         // add path to lookup view
         Finder::instance()->add_path(realpath(rtrim(__DIR__, '/') . '/../'));
         // build a response and return it
         return new Response(View::forge('_newrelic-status', ['result' => $res]), $res->getResultStatusCode());
     }));
 }