Class Directive<L>

java.lang.Object
akka.http.scaladsl.server.Directive<L>

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

    • Directive

      public Directive(Tuple<L> ev)
  • Method Details

    • 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<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)
    • ev

      public Tuple<L> ev()
    • 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 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<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,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,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<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)