All routes ultimately get handled by this handler if they have not already be redirected or responded.
188118
function handleRoute(seneca, options, request, reply, route, next) {
  if (options.parseBody) {
    return ReadBody(request, finish)
  }
  finish(null, request.body || {})

  // Express requires a body parser to work in production
  // This util creates a body obj without neededing a parser
  // but doesn't impact loading one in.
  function finish(err, body) {
    if (err) {
      return next(err)
    }

    // This is what the seneca handler will get
    // Note! request$ and response$ will be stripped
    // if the message is sent over transport.
    const payload = {
      request$: request,
      response$: reply,
      args: {
        body: body,
        route: route,
        params: request.params,
        query: request.query,
        user: request.user || null
      }
    }

    // Call the seneca action specified in the config
    seneca.act(route.pattern, payload, (err, response) => {
      if (err) {
        return next(err)
      }

      // Redirect or reply depending on config.
      if (route.redirect) {
        return reply.redirect(route.redirect)
      }
      if (route.autoreply) {
        return reply.send(response)
      }
    })
  }
}
236981
public Router all(@NotNull final Pattern regex, @NotNull final Middleware... handler) {
        get(regex, handler);
        put(regex, handler);
        post(regex, handler);
        delete(regex, handler);
        options(regex, handler);
        head(regex, handler);
        trace(regex, handler);
        connect(regex, handler);
        patch(regex, handler);
        return this;
    }
1124515
public static function all( $routes ) 
	{

		/* Call all functions that are to be executed before routing */
		foreach( self::$beforeFuncs as $beforeFunc ) {
			if( $beforeFunc[1] ) {
				call_user_func_array( $beforeFunc[0] , $beforeFunc[1] );
			} else {
				call_user_func( $beforeFunc[0] );
			}
		}

		self::$routes = $routes;
		$method = strtolower($_SERVER['REQUEST_METHOD']);
		$path = '/';
		$handler = null;
		$matched = array();
		if ( !empty ( $_SERVER['PATH_INFO'] ) ) {
			$path = $_SERVER['PATH_INFO'];
		} else if ( !empty ( $_SERVER['REQUEST_URI'] ) ) {
            $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
		}

		if ( isset($routes[$path] ) ) {
			if( is_array( $routes[$path] ) ) {
				$handler = $routes[$path][0];
			} else {
				$handler = $routes[$path];
			}
		} else if ( $routes ) {
			
			$regex = array(
				'/{i}/',
				'/{s}/',
				'/{a}/'
				);

			$replacements = array(
				'([\d]+)'	,
				'([a-zA-Z]+)',
				'([\w-]+)'
				);

			foreach ( $routes as $routePath => $routeDesc ){
				$routePath = preg_replace( $regex, $replacements, $routePath );
				if( preg_match( '#^/?' . $routePath . '/?$#', $path, $matches ) ){
					if( is_array( $routeDesc ) ) {
						$handler = $routeDesc[0];
						if( isset( $routeDesc[2] )) {
							$middleware = $routeDesc[2];
						}
					}
					else 
						$handler = $routeDesc;
					$matched = $matches;
					break;
				}
			}
		}
		unset( $matched[0] );

		if( isset($middleware) ){
			$newMatched = self::callFunction( $middleware, $matched, $method );
			/* If new wildcard param are there pass them to main handler */
			if( $newMatched ) { 
				self::callFunction( $handler, $newMatched, $method );
			} else {
				self::callFunction( $handler, $matched, $method );
			}
		} else {
			self::callFunction( $handler, $matched, $method );
		}

		/* Call all the function that are to be executed after routing */
		foreach( self::$afterFuncs as $afterFunc )
			if( $afterFunc[1] ) {
				call_user_func_array( $afterFunc[0] , $afterFunc[1] );
			} else {
				call_user_func( $afterFunc[0] );
			}
	}
844878
protected void onRouteDispatch(Request request, Response response) {
        final String requestPath = request.getPath();
        final String requestMethod = request.getMethod();

        if (shouldIgnorePath(requestPath)) {
            // NOT FOUND (404)
            RouteContext routeContext = routeContextFactory.createRouteContext(application, request, response, noMatches);
            ROUTE_CONTEXT_THREAD_LOCAL.set(routeContext);
            errorHandler.handle(HttpServletResponse.SC_NOT_FOUND, routeContext);
            ROUTE_CONTEXT_THREAD_LOCAL.remove();
            log.debug("Returned status code {} for {} '{}' (IGNORED)", response.getStatus(), requestMethod, requestPath);

            return;
        }

        List<RouteMatch> routeMatches = router.findRoutes(requestMethod, requestPath);
        RouteContext routeContext = routeContextFactory.createRouteContext(application, request, response, routeMatches);
        ROUTE_CONTEXT_THREAD_LOCAL.set(routeContext);

        try {
            if (routeMatches.isEmpty()) {
                if (notFoundRouteHandler != null) {
                    notFoundRouteHandler.handle(routeContext);
                } else {
                    // NOT FOUND (404)
                    errorHandler.handle(HttpConstants.StatusCode.NOT_FOUND, routeContext);
                }
            } else {
                processFlash(routeContext);
            }

            // execute the chain
            routeContext.next();

            if (!response.isCommitted()) {
                if (response.getStatus() == 0) {
                    log.debug("Status code not set for {} '{}'", requestMethod, requestPath);
                    response.notFound();
                }
                log.debug("Auto-committing response for {} '{}'", requestMethod, requestPath);
                if (response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST) {
                    // delegate response to the error handler.
                    // this will generate response content appropriate for the request
                    errorHandler.handle(response.getStatus(), routeContext);
                } else {
                    response.commit();
                }
            }
        } catch (Exception e) {
            errorHandler.handle(e, routeContext);
        } finally {
            routeContext.runFinallyRoutes();
            log.debug("Returned status code {} for {} '{}'", response.getStatus(), requestMethod, requestPath);
            ROUTE_CONTEXT_THREAD_LOCAL.remove();
        }
    }
1243028
function () {
      if (this.state) {
        _routerUtils.forEach(this.state.handlerInfos.slice().reverse(), function (handlerInfo) {
          var handler = handlerInfo.handler;
          _routerUtils.callHook(handler, 'exit');
        });
      }

      this.state = new _routerTransitionState.default();
      this.currentHandlerInfos = null;
    }
181611
protected function handleRouteCallback(Route $route, RouteCollection $matched, array $methods_matched)
    {
        // Handle the callback
        $returned = call_user_func(
            $route->getCallback(), // Instead of relying on the slower "invoke" magic
            $this->request,
            $this->response,
            $this->service,
            $this->app,
            $this, // Pass the Klein instance
            $matched,
            $methods_matched
        );

        if ($returned instanceof AbstractResponse) {
            $this->response = $returned;
        } else {
            // Otherwise, attempt to append the returned data
            try {
                $this->response->append($returned);
            } catch (LockedResponseException $e) {
                // Do nothing, since this is an automated behavior
            }
        }
    }
595085
public void dispatch(Request request, Response response) throws IOException, ServletException {
        onPreDispatch(request, response);
        onRouteDispatch(request, response);
        onPostDispatch(request, response);
    }
64818
def is_redirect(self):
        ''''''
        if self._response:
            status_code = self._response.status_code
            return status_code in self._codes \
                or status_code in self._repeat_codes
1349006
public function onAfterRoute()
    {
        $person = get_viewer();

        if ($person->admin()) {
            return;
        }

        AnService::get('repos:subscriptions.package');

        //if subscribe then unsubsribe
        if (isset($person->subscription) && $person->subscription->getTimeLeft() < 0) {

            $person->unsubscribe();

            $url = route('index.php?option=com_subscriptions&view=packages');
            AnService::get('application.dispatcher')
            ->getResponse()
            ->setRedirect($url)
            ->send();
        }

        return;
    }
1362505
@Override
    public boolean handleExecutionOutcome(
            FlowExecutionOutcome outcome, ActionRequest request, ActionResponse response) {
        if (this.redirectOnEnds != null && this.redirectOnEnds.containsKey(outcome.getId())) {
            final String redirectPath =
                    request.getContextPath() + this.redirectOnEnds.get(outcome.getId());
            try {
                response.sendRedirect(redirectPath);
                return true;
            } catch (IOException e) {
                this.logger.warn("Failed to send flow-end redirect to '" + redirectPath + "'");
            }
        }

        return false;
    }
682788
function securedRoute(seneca, options, context, method, middleware, route) {
  const routeArgs = [route.path].concat(middleware).concat([
    (request, reply, next) => {
      if (!request.user) {
        return reply.redirect(route.secure.fail)
      }
      handleRoute(seneca, options, request, reply, route, next)
    }
  ])

  context[method].apply(context, routeArgs)
}
1240956
def _handle_get(self, method, remainder, request=None):
        '''
        
        '''
        if request is None:
            self._raise_method_deprecation_warning(self._handle_get)

        # route to a get_all or get if no additional parts are available
        if not remainder or remainder == ['']:
            remainder = list(six.moves.filter(bool, remainder))
            controller = self._find_controller('get_all', 'get')
            if controller:
                self._handle_bad_rest_arguments(controller, remainder, request)
                return controller, []
            abort(405)

        method_name = remainder[-1]
        # check for new/edit/delete GET requests
        if method_name in ('new', 'edit', 'delete'):
            if method_name == 'delete':
                method_name = 'get_delete'
            controller = self._find_controller(method_name)
            if controller:
                return controller, remainder[:-1]

        match = self._handle_custom_action(method, remainder, request)
        if match:
            return match

        controller = self._lookup_child(remainder[0])
        if controller and not ismethod(controller):
            return lookup_controller(controller, remainder[1:], request)

        # finally, check for the regular get_one/get requests
        controller = self._find_controller('get_one', 'get')
        if controller:
            self._handle_bad_rest_arguments(controller, remainder, request)
            return controller, remainder

        abort(405)
262831
function route (message, cb) {
    assert(message, 'route requries a valid message')
    assert(cb && (typeof cb === 'function'), 'route requires a valid callback handler')

    if (message.pattern) {
      return pattern(message, cb)
    }

    if (message.response) {
      return response(message, cb)
    }

    malformed(message, cb)
  }
1317571
def handle_hooks(self, hooks, hook_type, *args):
        '''
        
        '''
        if hook_type not in ['before', 'on_route']:
            hooks = reversed(hooks)

        for hook in hooks:
            result = getattr(hook, hook_type)(*args)
            # on_error hooks can choose to return a Response, which will
            # be used instead of the standard error pages.
            if hook_type == 'on_error' and isinstance(result, WebObResponse):
                return result
1202438
@SuppressWarnings("unchecked")
  protected <T extends RaftRequest> void handleResponse(T request, BiFunction sender, int count, int selectionId, MemberId node, RaftResponse response, Throwable error, CompletableFuture future) {
    if (error == null) {
      log.trace("Received {} from {}", response, node);
      if (COMPLETE_PREDICATE.test(response)) {
        future.complete(response);
        selector.reset();
      } else {
        retryRequest(response.error().createException(), request, sender, count + 1, selectionId, future);
      }
    } else {
      if (error instanceof CompletionException) {
        error = error.getCause();
      }
      log.debug("{} failed! Reason: {}", request, error);
      if (error instanceof SocketException || error instanceof TimeoutException || error instanceof ClosedChannelException) {
        if (count < selector.members().size() + 1) {
          retryRequest(error, request, sender, count + 1, selectionId, future);
        } else {
          future.completeExceptionally(error);
        }
      } else {
        future.completeExceptionally(error);
      }
    }
  }
1210355
function Route(path) {
  this.path = path;
  this.stack = [];
  this.handle = compose(this.stack);

  debug('new %s', path);

  // route handlers for various http methods
  this.methods = {};
}
487540
public final boolean handle(HttpServletRequest req, HttpServletResponse res) {
		return handle(req, res, Request.getPath(req));
	}