Class Directive<L>
java.lang.Object
org.apache.pekko.http.scaladsl.server.Directive<L>
A directive that provides a tuple of values of type
L to create an inner route.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAdds helper functions toDirective0static classstatic classstatic class"Standard" transformers forDirective1.static class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic scala.Function1<scala.Function0<scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>>>, scala.Function1<RequestContext, scala.concurrent.Future<RouteResult>>> addByNameNullaryApply(Directive<scala.runtime.BoxedUnit> directive) Addsapplyto Directive0.static <L> scala.Function1<Object,scala.Function1<RequestContext, scala.concurrent.Future<RouteResult>>> addDirectiveApply(Directive<L> directive, ApplyConverter<L> hac) Addsapplyto all Directives with 1 or more extractions, which allows specifying an n-ary function to receive the extractions instead of a Function1[TupleX, Route].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 typeL, creates an instance of typeA(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).ev()<R> Directive<R>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 bythisDirective **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 ofrecoverthat 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 bumpabstract 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 typeL.tcollect(scala.PartialFunction<L, R> pf, scala.collection.immutable.Seq<Rejection> rejections, Tupler<R> tupler) If the givenPartialFunctionis defined for the input, maps this directive with the given function, which can produce either a tuple or any other value.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>Flatmaps this directive using the given function.Maps over this directive using the given function, which can produce either a tuple or any other value (which will then we wrapped into aTuple1).Directive<scala.runtime.BoxedUnit>Creates a newpekko.http.scaladsl.server.Directive0, which passes if the given predicate matches the current extractions or rejects with the given rejections.
-
Constructor Details
-
Directive
-
-
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
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, addDirectiveApplyscala.concurrent.Future<RouteResult>>> (Directive<L> directive, ApplyConverter<L> hac) Addsapplyto 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>>>, addByNameNullaryApplyscala.Function1<RequestContext, scala.concurrent.Future<RouteResult>>> (Directive<scala.runtime.BoxedUnit> directive) Addsapplyto Directive0. Note: Theapplyparameter 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 bumpINTERNAL API
- Parameters:
underlying- (undocumented)- Returns:
- (undocumented)
-
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 typeL.tapplyis short for "tuple-apply". Usually, you will use the regularapplymethod instead, which is added by an implicit conversion (seeDirective.addDirectiveApply).- Parameters:
f- (undocumented)- Returns:
- (undocumented)
-
or
Joins two directives into one which runs the second directive if the first one rejects.- Parameters:
that- (undocumented)- Returns:
- (undocumented)
-
and
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
Converts this directive into one which, instead of a tuple of typeL, creates an instance of typeA(which is usually a case class).- Parameters:
constructor- (undocumented)- Returns:
- (undocumented)
-
tmap
Maps over this directive using the given function, which can produce either a tuple or any other value (which will then we wrapped into aTuple1).- Parameters:
f- (undocumented)tupler- (undocumented)- Returns:
- (undocumented)
-
tflatMap
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 newpekko.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 givenPartialFunctionis 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 bythisDirective **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 ofrecoverthat only recovers from rejections handled by the given PartialFunction.- Parameters:
recovery- (undocumented)evidence$3- (undocumented)- Returns:
- (undocumented)
-