Routes requests to appropriate handlers.  Performs request path cleanup
 and several sanity checks prior to attempting to handle the request.

 @return a Rack response object.
541323
def route
      # Sanitize the URI:
      # * Unescape escaped characters
      # * Replace runs of / with a single /
      path_info = Rack::Utils.unescape(request.path_info).gsub(%r{/+}, '/')

      ROUTES.each do |path_matcher, verb, handler|
        path_info.match(path_matcher) do |match|
          @repository_uri = match[1]
          @request_verb = verb

          return method_not_allowed unless verb == request.request_method
          return bad_request if bad_uri?(@repository_uri)

          git.repository_path = root + @repository_uri
          return not_found unless git.exist?

          return send(handler, *match[2..-1])
        end
      end
      not_found
    end
748685
public static RouteInfo of(ActionContext context) {
        H.Method m = context.req().method();
        String path = context.req().url();
        RequestHandler handler = context.handler();
        if (null == handler) {
            handler = UNKNOWN_HANDLER;
        }
        return new RouteInfo(m, path, handler);
    }
668730
def routes(cls, application=None):
        
        if application:
            for route in cls._routes:
                application.add_handlers(route['host'], route['spec'])
        else:
            return [route['spec'] for route in cls._routes]
468909
private function swishAfter()
  {
    $events = $this;
    return function($route) use ($events) {
      $events->handleResponse($route->response);
      return Events::trigger('routes.handle', [$route]);
    };
  }
610982
protected boolean routingToAction(HttpServletRequest request, HttpServletResponse response, String contextPath, String requestPath,
            String actionName, String paramPath, ActionExecute execByParam) throws IOException, ServletException {
        if (execByParam != null) { // already found
            processAction(request, response, execByParam, paramPath); // #to_action
            return true;
        }
        final OptionalThing<ActionExecute> found = LaActionExecuteUtil.findActionExecute(actionName, request);
        if (found.isPresent()) { // not use lambda because of throws definition
            final ActionExecute execute = found.get();
            if (needsTrailingSlashRedirect(request, requestPath, execute)) { // index() or by request parameter
                redirectWithTrailingSlash(request, response, contextPath, requestPath);
            } else {
                processAction(request, response, execute, null); // #to_action
            }
            return true;
        } else { // e.g. not found index()
            return false;
        }
    }
265276
public Observable<Page<RouteFilterInner>> listAsync() {
        return listWithServiceResponseAsync()
            .map(new Func1<ServiceResponse<Page<RouteFilterInner>>, Page<RouteFilterInner>>() {
                @Override
                public Page<RouteFilterInner> call(ServiceResponse<Page<RouteFilterInner>> response) {
                    return response.body();
                }
            });
    }
1253509
def _response(status, body=nil, headers={})
      body = [body].compact
      headers = headers.merge("Content-Type" => "application/json")
      Rack::Response.new(body, status, headers).finish
    end
74750
public Routed<Object> route(M method, String path) {
    return router.route(method, path);
  }
521139
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $route = $this->router->dispatch($request->getMethod(), rawurldecode($request->getUri()->getPath()));

        if ($route[0] === Dispatcher::NOT_FOUND) {
            return $this->createResponse(404);
        }

        if ($route[0] === Dispatcher::METHOD_NOT_ALLOWED) {
            return $this->createResponse(405)->withHeader('Allow', implode(', ', $route[1]));
        }

        foreach ($route[2] as $name => $value) {
            $request = $request->withAttribute($name, $value);
        }

        $request = $this->setHandler($request, $route[1]);

        return $handler->handle($request);
    }
904370
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $requestPath = $this->getNormalizedPath($request);

        foreach ($this->middlewares as $pathPrefix => $middleware) {
            if (strpos($requestPath, $pathPrefix) === 0) {
                return $handler->handle(
                    $this->unprefixedRequest($request, $pathPrefix)
                        ->withAttribute($this->attribute, $middleware)
                );
            }
        }

        if ($this->continueOnError) {
            return $handler->handle($request);
        }

        return $this->responseFactory->createResponse(404);
    }
1105070
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $matcher = $this->router->getMatcher();
        $route = $matcher->match($request);
        if (!$route) {
            $failedRoute = $matcher->getFailedRoute();
            $request = $request->withAttribute('polus:route', $failedRoute);
            $response = new Response();
            switch ($failedRoute->failedRule) {
                case 'Aura\Router\Rule\Allows':
                    $response = $response->withStatus(405)->withHeader('Allow', implode(', ', $failedRoute->allows)); // 405 METHOD NOT ALLOWED
                case 'Aura\Router\Rule\Accepts':
                    $response = $response->withStatus(406); // 406 NOT ACCEPTABLE
                default:
                    $response = $response->withStatus(404); // 404 NOT FOUND
            }
            return $response;
        } else {
            $request = $request->withAttribute('polus:route', $route);
            foreach ($route->attributes as $name => $value) {
                $request = $request->withAttribute($name, $value);
            }
        }
        return $handler->handle($request);
    }
63867
private function prepareOptionsResponse()
    {
        ob_clean();

        // Determine which options have been set up for this route based on the registered routes
        $optionsForRoute = $this->router->getOptions($this->request);
        $methodsAllowed = [RequestMethod::OPTIONS];

        foreach ($optionsForRoute as $route) {
            // Extend the set of acceptable methods with the ones set up for this route
            $acceptableMethods = $route->getAcceptableMethods();
            $methodsAllowed = array_merge_recursive($methodsAllowed, $acceptableMethods);
        }

        array_unique($methodsAllowed);

        $this->response = new Response();
        $this->response->setResponseCode(ResponseCode::HTTP_OK);
        $this->response->setHeader('Allow', implode(',', $methodsAllowed));
        $this->response->setBody('');

        $this->context->registerInstance($this->response);

        $this->finalizeOutputBuffer();
    }
229059
def call(env)
      req = Rack::Request.new(env)
      resp = Rack::Response.new
      return resp.finish if !req.post?
      resp.write process(req.body.read)
      resp.finish
    end
858708
public Observable<Page<RouteTableInner>> listAsync() {
        return listWithServiceResponseAsync()
            .map(new Func1<ServiceResponse<Page<RouteTableInner>>, Page<RouteTableInner>>() {
                @Override
                public Page<RouteTableInner> call(ServiceResponse<Page<RouteTableInner>> response) {
                    return response.body();
                }
            });
    }
979116
function serve(root, route, opts) {
  opts = opts || {};
  route = route || '/';
  assert(root, 'root directory is required to serve files');

  // options
  debug('static "%s" "%s" %j', route, root, opts);
  opts.root = resolve(root);
  opts.index = opts.index || 'index.html';

  routes[route] = opts;
  return function *serve(next) {
    yield* next;
    debug('path: "%s"', this.path);
    var route = this.path.split('/')[1] || '/';
    if (this.method != 'HEAD' && this.method != 'GET') return;
    // response is already handled
    if (this.body != null || this.status != 404) return;

    yield send(this, this.path.slice(1 + route.length) || '/', routes[route]);
  };
}
441025
function Router() {
    var resources = {};

    // Public methods
    this.addRoute = function(resource) {
        var mPoint = resource.getMountPoint();

        if (typeof(resources[mPoint]) === 'undefined') {
            resources[mPoint] = resource;
        } else {
            resources[mPoint].update(resource);
        }
    };

    this.dispatch = function(locals) {
        var accept = locals.getAcceptedTypes();
        var request = locals.getRequest();
        var dispatched = false;
        var header;
        var mountPoint;
        var resource;

        locals.updateResponse(404);
        // Iterate over the resources
        for (mountPoint in resources) {
            // Did anybody flush already?
            resource = resources[mountPoint];
            // Does your URL definition matches this path?
            if (resource.matchesURL(request.path)) {
                locals.updateResponse(405);
                // Do you handle this method?
                if (resource.allowsMethod(request.method)) {
                    locals.updateResponse(406);
                    // Do you understand this format?
                    if (resource.acceptsType(accept, request.method)) {
                        locals.updateResponse(200);
                        // It's all yours
                        resource.takeOver(locals);
                        // And we set a flag announcing it was dispatched
                        dispatched = true;
                    }
                } else {
                    header = resource.getMethods().join(', ');
                    locals.getResponse().setHeader('Allow', header);
                }
            }
        }

        // Each resource emits a 'Resource:postRequest' event that flushes
        // the response. If no resource was found, that event was not emitted
        // and we need to do it manually.
        if (!dispatched) {
            locals.emit('Resource:completed');
            locals.emit('Resource:preRequest');
            locals.emit('Resource:postRequest');
        }
    };
}
822541
def get(path, params = nil, headers = {})
      response = http_client.get(request_uri(path), params, request_headers(headers))
      if response.status == 200
        parse_response(response)
      else
        handle_error_response(response)
      end
    end