Class Directive<L>


  • public abstract class Directive<L>
    extends java.lang.Object
    A directive that provides a tuple of values of type L to create an inner route.
    • Constructor Summary

      Constructors 
      Constructor Description
      Directive​(Tuple<L> ev)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static scala.Function1<scala.Function0<scala.Function1<RequestContext,​scala.concurrent.Future<RouteResult>>>,​scala.Function1<RequestContext,​scala.concurrent.Future<RouteResult>>> addByNameNullaryApply​(Directive<scala.runtime.BoxedUnit> directive)
      Adds apply to Directive0.
      static <L> scala.Function1<java.lang.Object,​scala.Function1<RequestContext,​scala.concurrent.Future<RouteResult>>> addDirectiveApply​(Directive<L> directive, ApplyConverter<L> hac)
      Adds apply to all Directives with 1 or more extractions, which allows specifying an n-ary function to receive the extractions instead of a Function1[TupleX, Route].
      java.lang.Object and​(ConjunctionMagnet<L> magnet)
      Joins two directives into one which extracts the concatenation of its base directive extractions.
      static <T> Directive<T> apply​(scala.Function1<scala.Function1<T,​scala.Function1<RequestContext,​scala.concurrent.Future<RouteResult>>>,​scala.Function1<RequestContext,​scala.concurrent.Future<RouteResult>>> f, Tuple<T> evidence$4)
      Constructs a directive from a function literal.
      <A> Directive<scala.Tuple1<A>> as​(ConstructFromTuple<L,​A> constructor)
      Converts this directive into one which, instead of a tuple of type L, creates an instance of type A (which is usually a case class).
      static Directive<scala.runtime.BoxedUnit> Empty()
      A Directive that always passes the request on to its inner route (i.e. does nothing).
      Tuple<L> ev()  
      <R> Directive<R> or​(Directive<R> that)
      Joins two directives into one which runs the second directive if the first one rejects.
      <R> Directive<R> recover​(scala.Function1<scala.collection.immutable.Seq<Rejection>,​Directive<R>> recovery, Tuple<R> evidence$2)
      Creates a new directive that is able to recover from rejections that were produced by this Directive **before the inner route was applied**.
      <R> Directive<R> recoverPF​(scala.PartialFunction<scala.collection.immutable.Seq<Rejection>,​Directive<R>> recovery, Tuple<R> evidence$3)
      Variant of recover that only recovers from rejections handled by the given PartialFunction.
      static <T> Directive.SingleValueModifiers<T> SingleValueModifiers​(Directive<scala.Tuple1<T>> underlying)
      previous, non-value class implementation kept around for binary compatibility TODO: remove with next binary incompatible release bump
      abstract scala.Function1<RequestContext,​scala.concurrent.Future<RouteResult>> tapply​(scala.Function1<L,​scala.Function1<RequestContext,​scala.concurrent.Future<RouteResult>>> f)
      Calls the inner route with a tuple of extracted values of type L.
      <R> Directive<java.lang.Object> tcollect​(scala.PartialFunction<L,​R> pf, scala.collection.immutable.Seq<Rejection> rejections, Tupler<R> tupler)
      If the given PartialFunction is defined for the input, maps this directive with the given function, which can produce either a tuple or any other value.
      Directive<L> tfilter​(scala.Function1<L,​java.lang.Object> predicate, scala.collection.immutable.Seq<Rejection> rejections)
      Creates a new directive of the same type, which passes if the given predicate matches the current extractions or rejects with the given rejections.
      <R> Directive<R> tflatMap​(scala.Function1<L,​Directive<R>> f, Tuple<R> evidence$1)
      Flatmaps this directive using the given function.
      <R> Directive<java.lang.Object> tmap​(scala.Function1<L,​R> f, Tupler<R> tupler)
      Maps over this directive using the given function, which can produce either a tuple or any other value (which will then we wrapped into a Tuple1).
      Directive<scala.runtime.BoxedUnit> trequire​(scala.Function1<L,​java.lang.Object> predicate, scala.collection.immutable.Seq<Rejection> rejections)
      Creates a new akka.http.scaladsl.server.Directive0, which passes if the given predicate matches the current extractions or rejects with the given rejections.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Directive

        public Directive​(Tuple<L> ev)
    • Method Detail

      • apply

        public static <T> Directive<T> apply​(scala.Function1<scala.Function1<T,​scala.Function1<RequestContext,​scala.concurrent.Future<RouteResult>>>,​scala.Function1<RequestContext,​scala.concurrent.Future<RouteResult>>> f,
                                             Tuple<T> evidence$4)
        Constructs a directive from a function literal.
        Parameters:
        f - (undocumented)
        evidence$4 - (undocumented)
        Returns:
        (undocumented)
      • Empty

        public static Directive<scala.runtime.BoxedUnit> Empty()
        A Directive that always passes the request on to its inner route (i.e. does nothing).
        Returns:
        (undocumented)
      • addDirectiveApply

        public static <L> scala.Function1<java.lang.Object,​scala.Function1<RequestContext,​scala.concurrent.Future<RouteResult>>> addDirectiveApply​(Directive<L> directive,
                                                                                                                                                               ApplyConverter<L> hac)
        Adds apply to all Directives with 1 or more extractions, which allows specifying an n-ary function to receive the extractions instead of a Function1[TupleX, Route].
        Parameters:
        directive - (undocumented)
        hac - (undocumented)
        Returns:
        (undocumented)
      • addByNameNullaryApply

        public static scala.Function1<scala.Function0<scala.Function1<RequestContext,​scala.concurrent.Future<RouteResult>>>,​scala.Function1<RequestContext,​scala.concurrent.Future<RouteResult>>> addByNameNullaryApply​(Directive<scala.runtime.BoxedUnit> directive)
        Adds apply to Directive0. Note: The apply parameter is call-by-name to ensure consistent execution behavior with the directives producing extractions.
        Parameters:
        directive - (undocumented)
        Returns:
        (undocumented)
      • SingleValueModifiers

        public static <T> Directive.SingleValueModifiers<T> SingleValueModifiers​(Directive<scala.Tuple1<T>> underlying)
        previous, non-value class implementation kept around for binary compatibility TODO: remove with next binary incompatible release bump

        INTERNAL API

        Parameters:
        underlying - (undocumented)
        Returns:
        (undocumented)
      • tapply

        public abstract scala.Function1<RequestContext,​scala.concurrent.Future<RouteResult>> tapply​(scala.Function1<L,​scala.Function1<RequestContext,​scala.concurrent.Future<RouteResult>>> f)
        Calls the inner route with a tuple of extracted values of type L.

        tapply is short for "tuple-apply". Usually, you will use the regular apply method instead, which is added by an implicit conversion (see Directive.addDirectiveApply).

        Parameters:
        f - (undocumented)
        Returns:
        (undocumented)
      • or

        public <R> Directive<R> or​(Directive<R> that)
        Joins two directives into one which runs the second directive if the first one rejects.
        Parameters:
        that - (undocumented)
        Returns:
        (undocumented)
      • and

        public java.lang.Object and​(ConjunctionMagnet<L> magnet)
        Joins two directives into one which extracts the concatenation of its base directive extractions. NOTE: Extraction joining is an O(N) operation with N being the number of extractions on the right-side.
        Parameters:
        magnet - (undocumented)
        Returns:
        (undocumented)
      • as

        public <A> Directive<scala.Tuple1<A>> as​(ConstructFromTuple<L,​A> constructor)
        Converts this directive into one which, instead of a tuple of type L, creates an instance of type A (which is usually a case class).
        Parameters:
        constructor - (undocumented)
        Returns:
        (undocumented)
      • tmap

        public <R> Directive<java.lang.Object> tmap​(scala.Function1<L,​R> f,
                                                    Tupler<R> tupler)
        Maps over this directive using the given function, which can produce either a tuple or any other value (which will then we wrapped into a Tuple1).
        Parameters:
        f - (undocumented)
        tupler - (undocumented)
        Returns:
        (undocumented)
      • tflatMap

        public <R> Directive<R> tflatMap​(scala.Function1<L,​Directive<R>> f,
                                         Tuple<R> evidence$1)
        Flatmaps this directive using the given function.
        Parameters:
        f - (undocumented)
        evidence$1 - (undocumented)
        Returns:
        (undocumented)
      • trequire

        public Directive<scala.runtime.BoxedUnit> trequire​(scala.Function1<L,​java.lang.Object> predicate,
                                                           scala.collection.immutable.Seq<Rejection> rejections)
        Creates a new akka.http.scaladsl.server.Directive0, which passes if the given predicate matches the current extractions or rejects with the given rejections.
        Parameters:
        predicate - (undocumented)
        rejections - (undocumented)
        Returns:
        (undocumented)
      • tfilter

        public Directive<L> tfilter​(scala.Function1<L,​java.lang.Object> predicate,
                                    scala.collection.immutable.Seq<Rejection> rejections)
        Creates a new directive of the same type, which passes if the given predicate matches the current extractions or rejects with the given rejections.
        Parameters:
        predicate - (undocumented)
        rejections - (undocumented)
        Returns:
        (undocumented)
      • tcollect

        public <R> Directive<java.lang.Object> tcollect​(scala.PartialFunction<L,​R> pf,
                                                        scala.collection.immutable.Seq<Rejection> rejections,
                                                        Tupler<R> tupler)
        If the given PartialFunction is defined for the input, maps this directive with the given function, which can produce either a tuple or any other value. If it is not defined however, the returned directive will reject with the given rejections.
        Parameters:
        pf - (undocumented)
        rejections - (undocumented)
        tupler - (undocumented)
        Returns:
        (undocumented)
      • recover

        public <R> Directive<R> recover​(scala.Function1<scala.collection.immutable.Seq<Rejection>,​Directive<R>> recovery,
                                        Tuple<R> evidence$2)
        Creates a new directive that is able to recover from rejections that were produced by this Directive **before the inner route was applied**.
        Parameters:
        recovery - (undocumented)
        evidence$2 - (undocumented)
        Returns:
        (undocumented)
      • recoverPF

        public <R> Directive<R> recoverPF​(scala.PartialFunction<scala.collection.immutable.Seq<Rejection>,​Directive<R>> recovery,
                                          Tuple<R> evidence$3)
        Variant of recover that only recovers from rejections handled by the given PartialFunction.
        Parameters:
        recovery - (undocumented)
        evidence$3 - (undocumented)
        Returns:
        (undocumented)