Example #1
0
 function httpRouteHasRequestUri(route $route, request\uri $requestUri)
 {
     $uri = clone $this;
     $uri->route = $route;
     $requestUri->recipientOfSegmentAtPositionIs(new request\uri\segment\position(), $uri);
     return $this;
 }
Example #2
0
 function httpRouteHasRequestUri(route $route, self $requestUri)
 {
     $requestUri->ifStartWithRequestUri($this, function () use($route) {
         $route->httpRequestUriHasRequestDataAggregator($this, new request\data\aggregator\blackhole());
     });
     return $this;
 }
Example #3
0
<?php

namespace estvoyage\risingsun\demo\http;

use estvoyage\risingsun\time, estvoyage\risingsun\bench, estvoyage\risingsun\output, estvoyage\risingsun\http\header, estvoyage\risingsun\http\method, estvoyage\risingsun\http\request, estvoyage\risingsun\http\router, estvoyage\risingsun\http\route, estvoyage\risingsun\http\route\endpoint;
require __DIR__ . '/../../vendor/autoload.php';
$stdout = new output\stdout();
$endpoint = new endpoint\blackhole();
$subRoute = new route\toUri(new route\uri\anyString(new request\data\name('foo')), $endpoint);
$uris = new route\prefilled($numberOfRoute = new route\prefilled\numberOfRoute(100), new route\prefilled\route\toUri($startRequestUri = new request\uri('/a'), $endpoint, $subRoute), new route\collection\indexed(new route\indexer\hash(), new route\collection()));
$router = new router(new route\toMethod(new method\get(), $uris), $endpoint, $endpoint);
$bench = new bench\average(new bench\total(new bench\second\micro(), new bench\loop\number(30000)));
$benchDurationFormater = new time\duration\formater\second\micro();
$requestForFirstRoute = new request\http(new method\get(), new request\uri($startRequestUri . '/firstroute'), new header\collection(), new request\data\collection());
$bench->recipientOfBenchDurationForCallableIs(function () use($router, $requestForFirstRoute) {
    $router->httpRequestIs($requestForFirstRoute);
}, new bench\formater\duration($stdout, new bench\name('East oriented first route: '), $benchDurationFormater));
$stdout->endOfLine();
$requestForLastRoute = new request\http(new method\get(), new request\uri($startRequestUri->httpRequestUriOffsetIs(new request\uri\offset($numberOfRoute->value - 1)) . '/lastroute'), new header\collection(), new request\data\collection());
$bench->recipientOfBenchDurationForCallableIs(function () use($router, $requestForLastRoute) {
    $router->httpRequestIs($requestForLastRoute);
}, new bench\formater\duration($stdout, new bench\name('East oriented last route: '), $benchDurationFormater));
$stdout->endOfLine();
$bench->recipientOfBenchDurationForCallableIs(function () use($router) {
    $router->httpRequestIs(new request\http(new method\get(), new request\uri('/' . uniqid()), new header\collection(), new request\data\collection()));
}, new bench\formater\duration($stdout, new bench\name('East oriented unknown route: '), $benchDurationFormater));
$stdout->endOfLine();