.. _routes-java: Routes ====== A ``Route`` itself is a function that operates on a ``RequestContext`` and returns a ``RouteResult``. The ``RequestContext`` is a data structure that contains the current request and auxiliary data like the so far unmatched path of the request URI that gets passed through the route structure. It also contains the current ``ExecutionContext`` and ``akka.stream.Materializer``, so that these don't have to be passed around manually. .. _request-context-java: RequestContext -------------- The ``RequestContext`` achieves two goals: it allows access to request data and it is a factory for creating a ``RouteResult``. A user-defined handler (see :ref:`handlers-java`) that is usually used at the leaf position of the route tree receives a ``RequestContext``, evaluates its content and then returns a result generated by one of the methods of the context. .. _route-result-java: RouteResult ----------- The ``RouteResult`` is an opaque structure that represents possible results of evaluating a route. A ``RouteResult`` can only be created by using one of the methods of the ``RequestContext``. A result can either be a response, if it was generated by one of the ``completeX`` methods, it can be an eventual result, i.e. a ``CompletionStage