Package akka.http.scaladsl.server
Class Directive<L>
- java.lang.Object
-
- akka.http.scaladsl.server.Directive<L>
-
public abstract class Directive<L> extends java.lang.Object
A directive that provides a tuple of values of typeL
to create an inner route.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Directive.Directive0Support
Adds helper functions toDirective0
static class
Directive.Directive0Support$
static class
Directive.SingleValueModifiers<T>
static class
Directive.SingleValueTransformers<T>
"Standard" transformers forDirective1
.static class
Directive.SingleValueTransformers$
-
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)
Addsapply
to Directive0.static <L> scala.Function1<java.lang.Object,scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>>>
addDirectiveApply(Directive<L> directive, ApplyConverter<L> hac)
Addsapply
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 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).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 bythis
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 ofrecover
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 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
.<R> Directive<java.lang.Object>
tcollect(scala.PartialFunction<L,R> pf, scala.collection.immutable.Seq<Rejection> rejections, Tupler<R> tupler)
If the givenPartialFunction
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 aTuple1
).Directive<scala.runtime.BoxedUnit>
trequire(scala.Function1<L,java.lang.Object> predicate, scala.collection.immutable.Seq<Rejection> rejections)
Creates a newakka.http.scaladsl.server.Directive0
, which passes if the given predicate matches the current extractions or rejects with the given rejections.
-
-
-
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)
Addsapply
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)
Addsapply
to Directive0. Note: Theapply
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 bumpINTERNAL 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 typeL
.tapply
is short for "tuple-apply". Usually, you will use the regularapply
method instead, which is added by an implicit conversion (seeDirective.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 typeL
, creates an instance of typeA
(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 aTuple1
).- 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 newakka.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 givenPartialFunction
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 bythis
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 ofrecover
that only recovers from rejections handled by the given PartialFunction.- Parameters:
recovery
- (undocumented)evidence$3
- (undocumented)- Returns:
- (undocumented)
-
-