Class BasicDirectives
- java.lang.Object
-
- akka.http.javadsl.server.directives.BasicDirectives
-
- Direct Known Subclasses:
CacheConditionDirectives
public abstract class BasicDirectives extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description BasicDirectives()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RoutecancelRejection(Rejection rejection, java.util.function.Supplier<Route> inner)Adds a TransformationRejection cancelling all rejections equal to the given one to the list of rejections potentially coming back from the inner route.RoutecancelRejections(java.lang.Iterable<java.lang.Class<?>> classes, java.util.function.Supplier<Route> inner)Adds a TransformationRejection cancelling all rejections of one of the given classes to the list of rejections potentially coming back from the inner route.RoutecancelRejections(java.util.function.Predicate<Rejection> filter, java.util.function.Supplier<Route> inner)Adds a TransformationRejection cancelling all rejections for which the given filter function returns true to the list of rejections potentially coming back from the inner route.<T> Routeextract(java.util.function.Function<RequestContext,T> extract, java.util.function.Function<T,Route> inner)Extracts a single value using the given function.RouteextractActorSystem(java.util.function.Function<akka.actor.ActorSystem,Route> inner)Extracts theActorSystemif the available Materializer is anActorMaterializer.RouteAdapterextractDataBytes(java.util.function.Function<akka.stream.javadsl.Source<akka.util.ByteString,java.lang.Object>,Route> inner)RouteextractEntity(java.util.function.Function<RequestEntity,Route> inner)Extracts the current http request entity.RouteextractExecutionContext(java.util.function.Function<scala.concurrent.ExecutionContextExecutor,Route> inner)Extracts theExecutionContextExecutorfrom theRequestContext.RouteextractLog(java.util.function.Function<akka.event.LoggingAdapter,Route> inner)Extracts theLoggingAdapterRouteAdapterextractMatchedPath(java.util.function.Function<java.lang.String,Route> inner)Extracts the already matched path from the RequestContext.RouteextractMaterializer(java.util.function.Function<akka.stream.Materializer,Route> inner)Extracts theMaterializerfrom theRequestContext.RouteAdapterextractParserSettings(java.util.function.Function<ParserSettings,Route> inner)Extracts theParserSettingsfrom theRequestContext.RouteAdapterextractRequest(java.util.function.Function<HttpRequest,Route> inner)Extracts the currentHttpRequestinstance.RouteAdapterextractRequestContext(java.util.function.Function<RequestContext,Route> inner)Extracts theRequestContextitself.RouteextractRequestEntity(java.util.function.Function<RequestEntity,Route> inner)Extracts theRequestEntityfrom theRequestContext.RouteAdapterextractSettings(java.util.function.Function<RoutingSettings,Route> inner)Extracts theRoutingSettingsfrom theRequestContext.RouteextractStrictEntity(scala.concurrent.duration.FiniteDuration timeout, long maxBytes, java.util.function.Function<HttpEntity.Strict,Route> inner)WARNING: This will read the entire request entity into memory and effectively disable streaming.RouteextractStrictEntity(scala.concurrent.duration.FiniteDuration timeout, java.util.function.Function<HttpEntity.Strict,Route> inner)WARNING: This will read the entire request entity into memory and effectively disable streaming.RouteAdapterextractUnmatchedPath(java.util.function.Function<java.lang.String,Route> inner)Extracts the yet unmatched path from the RequestContext.RouteAdapterextractUri(java.util.function.Function<Uri,Route> inner)Extracts the complete request URI.RoutemapInnerRoute(java.util.function.Function<Route,Route> f, java.util.function.Supplier<Route> inner)RoutemapRejections(java.util.function.Function<java.util.List<Rejection>,java.util.List<Rejection>> f, java.util.function.Supplier<Route> inner)RoutemapRequest(java.util.function.Function<HttpRequest,HttpRequest> f, java.util.function.Supplier<Route> inner)RoutemapRequestContext(java.util.function.Function<RequestContext,RequestContext> f, java.util.function.Supplier<Route> inner)RoutemapResponse(java.util.function.Function<HttpResponse,HttpResponse> f, java.util.function.Supplier<Route> inner)RoutemapResponseEntity(java.util.function.Function<ResponseEntity,ResponseEntity> f, java.util.function.Supplier<Route> inner)RoutemapResponseHeaders(java.util.function.Function<java.util.List<HttpHeader>,java.util.List<HttpHeader>> f, java.util.function.Supplier<Route> inner)RoutemapRouteResult(java.util.function.Function<RouteResult,RouteResult> f, java.util.function.Supplier<Route> inner)RoutemapRouteResultFuture(java.util.function.Function<java.util.concurrent.CompletionStage<RouteResult>,java.util.concurrent.CompletionStage<RouteResult>> f, java.util.function.Supplier<Route> inner)RoutemapRouteResultPF(scala.PartialFunction<RouteResult,RouteResult> f, java.util.function.Supplier<Route> inner)RoutemapRouteResultWith(java.util.function.Function<RouteResult,java.util.concurrent.CompletionStage<RouteResult>> f, java.util.function.Supplier<Route> inner)RoutemapRouteResultWithPF(scala.PartialFunction<RouteResult,java.util.concurrent.CompletionStage<RouteResult>> f, java.util.function.Supplier<Route> inner)RoutemapSettings(java.util.function.Function<RoutingSettings,RoutingSettings> f, java.util.function.Supplier<Route> inner)Runs the inner route with settings mapped by the given function.RoutemapUnmatchedPath(java.util.function.Function<java.lang.String,java.lang.String> f, java.util.function.Supplier<Route> inner)Transforms the unmatchedPath of the RequestContext using the given function.Routepass(java.util.function.Supplier<Route> inner)Always passes the request on to its inner route (i.e. does nothing with the request or the response).<T> Routeprovide(T t, java.util.function.Function<T,Route> inner)Injects the given value into a directive.RouterecoverRejections(java.util.function.Function<java.lang.Iterable<Rejection>,RouteResult> f, java.util.function.Supplier<Route> inner)RouterecoverRejectionsWith(java.util.function.Function<java.lang.Iterable<Rejection>,java.util.concurrent.CompletionStage<RouteResult>> f, java.util.function.Supplier<Route> inner)RoutetoStrictEntity(scala.concurrent.duration.FiniteDuration timeout, long maxBytes, java.util.function.Supplier<Route> inner)WARNING: This will read the entire request entity into memory and effectively disable streaming.RoutetoStrictEntity(scala.concurrent.duration.FiniteDuration timeout, java.util.function.Supplier<Route> inner)WARNING: This will read the entire request entity into memory and effectively disable streaming.RoutewithExecutionContext(scala.concurrent.ExecutionContextExecutor ec, java.util.function.Supplier<Route> inner)Runs its inner route with the given alternativeExecutionContextExecutor.RoutewithLog(akka.event.LoggingAdapter log, java.util.function.Supplier<Route> inner)Runs its inner route with the given alternativeLoggingAdapter.RoutewithMaterializer(akka.stream.Materializer mat, java.util.function.Supplier<Route> inner)Runs its inner route with the given alternativeMaterializer.RoutewithSettings(RoutingSettings s, java.util.function.Supplier<Route> inner)Runs its inner route with the given alternativeRoutingSettings.
-
-
-
Method Detail
-
cancelRejection
public Route cancelRejection(Rejection rejection, java.util.function.Supplier<Route> inner)
Adds a TransformationRejection cancelling all rejections equal to the given one to the list of rejections potentially coming back from the inner route.- Parameters:
rejection- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
cancelRejections
public Route cancelRejections(java.lang.Iterable<java.lang.Class<?>> classes, java.util.function.Supplier<Route> inner)
Adds a TransformationRejection cancelling all rejections of one of the given classes to the list of rejections potentially coming back from the inner route.- Parameters:
classes- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
cancelRejections
public Route cancelRejections(java.util.function.Predicate<Rejection> filter, java.util.function.Supplier<Route> inner)
Adds a TransformationRejection cancelling all rejections for which the given filter function returns true to the list of rejections potentially coming back from the inner route.- Parameters:
filter- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
extract
public <T> Route extract(java.util.function.Function<RequestContext,T> extract, java.util.function.Function<T,Route> inner)
Extracts a single value using the given function.- Parameters:
extract- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
extractActorSystem
public Route extractActorSystem(java.util.function.Function<akka.actor.ActorSystem,Route> inner)
Extracts theActorSystemif the available Materializer is anActorMaterializer. Otherwise throws an exception as it won't be able to extract the system from arbitrary materializers.- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
extractDataBytes
public RouteAdapter extractDataBytes(java.util.function.Function<akka.stream.javadsl.Source<akka.util.ByteString,java.lang.Object>,Route> inner)
- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
extractEntity
public Route extractEntity(java.util.function.Function<RequestEntity,Route> inner)
Extracts the current http request entity.- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
extractExecutionContext
public Route extractExecutionContext(java.util.function.Function<scala.concurrent.ExecutionContextExecutor,Route> inner)
Extracts theExecutionContextExecutorfrom theRequestContext.- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
extractLog
public Route extractLog(java.util.function.Function<akka.event.LoggingAdapter,Route> inner)
Extracts theLoggingAdapter- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
extractMatchedPath
public RouteAdapter extractMatchedPath(java.util.function.Function<java.lang.String,Route> inner)
Extracts the already matched path from the RequestContext.- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
extractMaterializer
public Route extractMaterializer(java.util.function.Function<akka.stream.Materializer,Route> inner)
Extracts theMaterializerfrom theRequestContext.- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
extractParserSettings
public RouteAdapter extractParserSettings(java.util.function.Function<ParserSettings,Route> inner)
Extracts theParserSettingsfrom theRequestContext.- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
extractRequest
public RouteAdapter extractRequest(java.util.function.Function<HttpRequest,Route> inner)
Extracts the currentHttpRequestinstance.- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
extractRequestContext
public RouteAdapter extractRequestContext(java.util.function.Function<RequestContext,Route> inner)
Extracts theRequestContextitself.- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
extractRequestEntity
public Route extractRequestEntity(java.util.function.Function<RequestEntity,Route> inner)
Extracts theRequestEntityfrom theRequestContext.- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
extractSettings
public RouteAdapter extractSettings(java.util.function.Function<RoutingSettings,Route> inner)
Extracts theRoutingSettingsfrom theRequestContext.- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
extractStrictEntity
public Route extractStrictEntity(scala.concurrent.duration.FiniteDuration timeout, java.util.function.Function<HttpEntity.Strict,Route> inner)
WARNING: This will read the entire request entity into memory and effectively disable streaming.To help protect against excessive memory use, the request will be aborted if the request is larger than allowed by the
akka.http.parsing.max-to-strict-bytesconfiguration setting.Converts the HttpEntity from the
RequestContextinto anHttpEntity.Strictand extracts it, or fails the route if unable to drain the entire request body within the timeout.- Parameters:
timeout- The directive is failed if the stream isn't completed after the given timeout.inner- (undocumented)- Returns:
- (undocumented)
-
extractStrictEntity
public Route extractStrictEntity(scala.concurrent.duration.FiniteDuration timeout, long maxBytes, java.util.function.Function<HttpEntity.Strict,Route> inner)
WARNING: This will read the entire request entity into memory and effectively disable streaming.To help protect against excessive memory use, the request will be aborted if the request is larger than allowed by the
akka.http.parsing.max-to-strict-bytesconfiguration setting.Converts the HttpEntity from the
RequestContextinto anHttpEntity.Strictand extracts it, or fails the route if unable to drain the entire request body within the timeout.- Parameters:
timeout- The directive is failed if the stream isn't completed after the given timeout.maxBytes- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
extractUnmatchedPath
public RouteAdapter extractUnmatchedPath(java.util.function.Function<java.lang.String,Route> inner)
Extracts the yet unmatched path from the RequestContext.- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
extractUri
public RouteAdapter extractUri(java.util.function.Function<Uri,Route> inner)
Extracts the complete request URI.- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
mapInnerRoute
public Route mapInnerRoute(java.util.function.Function<Route,Route> f, java.util.function.Supplier<Route> inner)
-
mapRejections
public Route mapRejections(java.util.function.Function<java.util.List<Rejection>,java.util.List<Rejection>> f, java.util.function.Supplier<Route> inner)
-
mapRequest
public Route mapRequest(java.util.function.Function<HttpRequest,HttpRequest> f, java.util.function.Supplier<Route> inner)
-
mapRequestContext
public Route mapRequestContext(java.util.function.Function<RequestContext,RequestContext> f, java.util.function.Supplier<Route> inner)
-
mapResponse
public Route mapResponse(java.util.function.Function<HttpResponse,HttpResponse> f, java.util.function.Supplier<Route> inner)
-
mapResponseEntity
public Route mapResponseEntity(java.util.function.Function<ResponseEntity,ResponseEntity> f, java.util.function.Supplier<Route> inner)
-
mapResponseHeaders
public Route mapResponseHeaders(java.util.function.Function<java.util.List<HttpHeader>,java.util.List<HttpHeader>> f, java.util.function.Supplier<Route> inner)
-
mapRouteResult
public Route mapRouteResult(java.util.function.Function<RouteResult,RouteResult> f, java.util.function.Supplier<Route> inner)
-
mapRouteResultFuture
public Route mapRouteResultFuture(java.util.function.Function<java.util.concurrent.CompletionStage<RouteResult>,java.util.concurrent.CompletionStage<RouteResult>> f, java.util.function.Supplier<Route> inner)
-
mapRouteResultPF
public Route mapRouteResultPF(scala.PartialFunction<RouteResult,RouteResult> f, java.util.function.Supplier<Route> inner)
-
mapRouteResultWith
public Route mapRouteResultWith(java.util.function.Function<RouteResult,java.util.concurrent.CompletionStage<RouteResult>> f, java.util.function.Supplier<Route> inner)
-
mapRouteResultWithPF
public Route mapRouteResultWithPF(scala.PartialFunction<RouteResult,java.util.concurrent.CompletionStage<RouteResult>> f, java.util.function.Supplier<Route> inner)
-
mapSettings
public Route mapSettings(java.util.function.Function<RoutingSettings,RoutingSettings> f, java.util.function.Supplier<Route> inner)
Runs the inner route with settings mapped by the given function.- Parameters:
f- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
mapUnmatchedPath
public Route mapUnmatchedPath(java.util.function.Function<java.lang.String,java.lang.String> f, java.util.function.Supplier<Route> inner)
Transforms the unmatchedPath of the RequestContext using the given function.- Parameters:
f- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
pass
public Route pass(java.util.function.Supplier<Route> inner)
Always passes the request on to its inner route (i.e. does nothing with the request or the response).- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
provide
public <T> Route provide(T t, java.util.function.Function<T,Route> inner)
Injects the given value into a directive.- Parameters:
t- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
recoverRejections
public Route recoverRejections(java.util.function.Function<java.lang.Iterable<Rejection>,RouteResult> f, java.util.function.Supplier<Route> inner)
-
recoverRejectionsWith
public Route recoverRejectionsWith(java.util.function.Function<java.lang.Iterable<Rejection>,java.util.concurrent.CompletionStage<RouteResult>> f, java.util.function.Supplier<Route> inner)
-
toStrictEntity
public Route toStrictEntity(scala.concurrent.duration.FiniteDuration timeout, java.util.function.Supplier<Route> inner)
WARNING: This will read the entire request entity into memory and effectively disable streaming.To help protect against excessive memory use, the request will be aborted if the request is larger than allowed by the
akka.http.parsing.max-to-strict-bytesconfiguration setting.Extracts the
RequestContextitself with the strict HTTP entity, or fails the route if unable to drain the entire request body within the timeout.- Parameters:
timeout- The directive is failed if the stream isn't completed after the given timeout.inner- (undocumented)- Returns:
- (undocumented)
-
toStrictEntity
public Route toStrictEntity(scala.concurrent.duration.FiniteDuration timeout, long maxBytes, java.util.function.Supplier<Route> inner)
WARNING: This will read the entire request entity into memory and effectively disable streaming.To help protect against excessive memory use, the request will be aborted if the request is larger than allowed by the
akka.http.parsing.max-to-strict-bytesconfiguration setting.Extracts the
RequestContextitself with the strict HTTP entity, or fails the route if unable to drain the entire request body within the timeout.- Parameters:
timeout- The directive is failed if the stream isn't completed after the given timeout.maxBytes- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
withExecutionContext
public Route withExecutionContext(scala.concurrent.ExecutionContextExecutor ec, java.util.function.Supplier<Route> inner)
Runs its inner route with the given alternativeExecutionContextExecutor.- Parameters:
ec- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
withLog
public Route withLog(akka.event.LoggingAdapter log, java.util.function.Supplier<Route> inner)
Runs its inner route with the given alternativeLoggingAdapter.- Parameters:
log- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
withMaterializer
public Route withMaterializer(akka.stream.Materializer mat, java.util.function.Supplier<Route> inner)
Runs its inner route with the given alternativeMaterializer.- Parameters:
mat- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
withSettings
public Route withSettings(RoutingSettings s, java.util.function.Supplier<Route> inner)
Runs its inner route with the given alternativeRoutingSettings.- Parameters:
s- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
-