Class BasicDirectives
- Direct Known Subclasses:
- CacheConditionDirectives
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptioncancelRejection(Rejection rejection, 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.cancelRejections(Iterable<Class<?>> classes, 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.cancelRejections(Predicate<Rejection> filter, 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(Function<RequestContext, T> extract, Function<T, Route> inner) Extracts a single value using the given function.extractActorSystem(Function<org.apache.pekko.actor.ActorSystem, Route> inner) Extracts thepekko.actor.ActorSystemif the Materializer is available.extractDataBytes(Function<org.apache.pekko.stream.javadsl.Source<org.apache.pekko.util.ByteString, Object>, Route> inner) Extracts the entitiesdataBytespekko.stream.javadsl.Sourcefrom thepekko.http.javadsl.server.RequestContext.extractEntity(Function<RequestEntity, Route> inner) Extracts the current http request entity.extractExecutionContext(Function<scala.concurrent.ExecutionContextExecutor, Route> inner) Extracts theExecutionContextExecutorfrom theRequestContext.extractLog(Function<org.apache.pekko.event.LoggingAdapter, Route> inner) Extracts theLoggingAdapterextractMatchedPath(Function<String, Route> inner) Extracts the already matched path from the RequestContext.extractMaterializer(Function<org.apache.pekko.stream.Materializer, Route> inner) Extracts theMaterializerfrom theRequestContext.Extracts thepekko.http.javadsl.settings.ParserSettingsfrom thepekko.http.javadsl.server.RequestContext.extractRequest(Function<HttpRequest, Route> inner) Extracts the currentHttpRequestinstance.Extracts thepekko.http.javadsl.server.RequestContextitself.Extracts thepekko.http.javadsl.model.RequestEntityfrom thepekko.http.javadsl.server.RequestContext.extractSettings(Function<RoutingSettings, Route> inner) Extracts theRoutingSettingsfrom thepekko.http.javadsl.server.RequestContext.extractStrictEntity(Duration timeout, long maxBytes, Function<HttpEntity.Strict, Route> inner) WARNING: This will read the entire request entity into memory and effectively disable streaming.extractStrictEntity(Duration timeout, Function<HttpEntity.Strict, Route> inner) WARNING: This will read the entire request entity into memory and effectively disable streaming.extractStrictEntity(scala.concurrent.duration.FiniteDuration timeout, long maxBytes, Function<HttpEntity.Strict, Route> inner) Deprecated.extractStrictEntity(scala.concurrent.duration.FiniteDuration timeout, Function<HttpEntity.Strict, Route> inner) Deprecated.As of 1.3.0, use the overloaded method taking ajava.time.Durationinstead.extractUnmatchedPath(Function<String, Route> inner) Extracts the yet unmatched path from the RequestContext.extractUri(Function<Uri, Route> inner) Extracts the complete request URI.mapRequest(Function<HttpRequest, HttpRequest> f, Supplier<Route> inner) mapRequestContext(Function<RequestContext, RequestContext> f, Supplier<Route> inner) mapResponse(Function<HttpResponse, HttpResponse> f, Supplier<Route> inner) mapResponseEntity(Function<ResponseEntity, ResponseEntity> f, Supplier<Route> inner) mapResponseHeaders(Function<List<HttpHeader>, List<HttpHeader>> f, Supplier<Route> inner) mapRouteResult(Function<RouteResult, RouteResult> f, Supplier<Route> inner) mapRouteResultFuture(Function<CompletionStage<RouteResult>, CompletionStage<RouteResult>> f, Supplier<Route> inner) mapRouteResultPF(scala.PartialFunction<RouteResult, RouteResult> f, Supplier<Route> inner) mapRouteResultWith(Function<RouteResult, CompletionStage<RouteResult>> f, Supplier<Route> inner) mapRouteResultWithPF(scala.PartialFunction<RouteResult, CompletionStage<RouteResult>> f, Supplier<Route> inner) mapSettings(Function<RoutingSettings, RoutingSettings> f, Supplier<Route> inner) Runs the inner route with settings mapped by the given function.Transforms the unmatchedPath of the RequestContext using the given function.Always passes the request on to its inner route (i.e. does nothing with the request or the response).<T> RouteInjects the given value into a directive.recoverRejections(Function<Iterable<Rejection>, RouteResult> f, Supplier<Route> inner) recoverRejectionsWith(Function<Iterable<Rejection>, CompletionStage<RouteResult>> f, Supplier<Route> inner) toStrictEntity(Duration timeout, long maxBytes, Supplier<Route> inner) WARNING: This will read the entire request entity into memory and effectively disable streaming.toStrictEntity(Duration timeout, Supplier<Route> inner) WARNING: This will read the entire request entity into memory and effectively disable streaming.toStrictEntity(scala.concurrent.duration.FiniteDuration timeout, long maxBytes, Supplier<Route> inner) Deprecated.As of 1.3.0, use the overloaded method taking ajava.time.Durationinstead.toStrictEntity(scala.concurrent.duration.FiniteDuration timeout, Supplier<Route> inner) Deprecated.As of 1.3.0, use the overloaded method taking ajava.time.Durationinstead.withExecutionContext(scala.concurrent.ExecutionContextExecutor ec, Supplier<Route> inner) Runs its inner route with the given alternativeExecutionContextExecutor.Runs its inner route with the given alternativeLoggingAdapter.withMaterializer(org.apache.pekko.stream.Materializer mat, Supplier<Route> inner) Runs its inner route with the given alternativepekko.stream.Materializer.withSettings(RoutingSettings s, Supplier<Route> inner) Runs its inner route with the given alternativeRoutingSettings.
- 
Constructor Details- 
BasicDirectivespublic BasicDirectives()
 
- 
- 
Method Details- 
cancelRejectionAdds 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)
 
- 
cancelRejectionsAdds 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)
 
- 
cancelRejectionsAdds 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)
 
- 
extractExtracts a single value using the given function.- Parameters:
- extract- (undocumented)
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
extractActorSystemExtracts thepekko.actor.ActorSystemif the Materializer is available. Otherwise throws an exception as it won't be able to extract the system from arbitrary materializers.- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
extractDataBytespublic RouteAdapter extractDataBytes(Function<org.apache.pekko.stream.javadsl.Source<org.apache.pekko.util.ByteString, Object>, Route> inner) Extracts the entitiesdataBytespekko.stream.javadsl.Sourcefrom thepekko.http.javadsl.server.RequestContext.- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
extractEntityExtracts the current http request entity.- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
extractExecutionContextpublic Route extractExecutionContext(Function<scala.concurrent.ExecutionContextExecutor, Route> inner) Extracts theExecutionContextExecutorfrom theRequestContext.- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
extractLogExtracts theLoggingAdapter- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
extractMatchedPathExtracts the already matched path from the RequestContext.- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
extractMaterializerExtracts theMaterializerfrom theRequestContext.- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
extractParserSettingsExtracts thepekko.http.javadsl.settings.ParserSettingsfrom thepekko.http.javadsl.server.RequestContext.- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
extractRequestExtracts the currentHttpRequestinstance.- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
extractRequestContextExtracts thepekko.http.javadsl.server.RequestContextitself.- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
extractRequestEntityExtracts thepekko.http.javadsl.model.RequestEntityfrom thepekko.http.javadsl.server.RequestContext.- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
extractSettingsExtracts theRoutingSettingsfrom thepekko.http.javadsl.server.RequestContext.- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
extractStrictEntitypublic Route extractStrictEntity(scala.concurrent.duration.FiniteDuration timeout, Function<HttpEntity.Strict, Route> inner) Deprecated.As of 1.3.0, use the overloaded method taking ajava.time.Durationinstead.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 pekko.http.parsing.max-to-strict-bytesconfiguration setting.Converts the HttpEntity from the pekko.http.javadsl.server.RequestContextinto anpekko.http.javadsl.model.HttpEntity.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)
 
- 
extractStrictEntityWARNING: 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 pekko.http.parsing.max-to-strict-bytesconfiguration setting.Converts the HttpEntity from the pekko.http.javadsl.server.RequestContextinto anpekko.http.javadsl.model.HttpEntity.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)
- Since:
- 1.3.0
 
- 
extractStrictEntitypublic Route extractStrictEntity(scala.concurrent.duration.FiniteDuration timeout, long maxBytes, Function<HttpEntity.Strict, Route> inner) Deprecated.As of 1.3.0, use the overloaded method taking ajava.time.Durationinstead.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 pekko.http.parsing.max-to-strict-bytesconfiguration setting.Converts the HttpEntity from the pekko.http.javadsl.server.RequestContextinto anpekko.http.javadsl.model.HttpEntity.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)
 
- 
extractStrictEntitypublic Route extractStrictEntity(Duration timeout, long maxBytes, 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 pekko.http.parsing.max-to-strict-bytesconfiguration setting.Converts the HttpEntity from the pekko.http.javadsl.server.RequestContextinto anpekko.http.javadsl.model.HttpEntity.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)
- Since:
- 1.3.0
 
- 
extractUnmatchedPathExtracts the yet unmatched path from the RequestContext.- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
extractUriExtracts the complete request URI.- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
mapInnerRoute
- 
mapRejections
- 
mapRequest
- 
mapRequestContext
- 
mapResponse
- 
mapResponseEntity
- 
mapResponseHeaderspublic Route mapResponseHeaders(Function<List<HttpHeader>, List<HttpHeader>> f, Supplier<Route> inner) 
- 
mapRouteResult
- 
mapRouteResultFuturepublic Route mapRouteResultFuture(Function<CompletionStage<RouteResult>, CompletionStage<RouteResult>> f, Supplier<Route> inner) 
- 
mapRouteResultPFpublic Route mapRouteResultPF(scala.PartialFunction<RouteResult, RouteResult> f, Supplier<Route> inner) 
- 
mapRouteResultWithpublic Route mapRouteResultWith(Function<RouteResult, CompletionStage<RouteResult>> f, Supplier<Route> inner) 
- 
mapRouteResultWithPFpublic Route mapRouteResultWithPF(scala.PartialFunction<RouteResult, CompletionStage<RouteResult>> f, Supplier<Route> inner) 
- 
mapSettingsRuns the inner route with settings mapped by the given function.- Parameters:
- f- (undocumented)
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
mapUnmatchedPathTransforms the unmatchedPath of the RequestContext using the given function.- Parameters:
- f- (undocumented)
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
passAlways passes the request on to its inner route (i.e. does nothing with the request or the response).- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
provideInjects the given value into a directive.- Parameters:
- t- (undocumented)
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
recoverRejections
- 
recoverRejectionsWithpublic Route recoverRejectionsWith(Function<Iterable<Rejection>, CompletionStage<RouteResult>> f, Supplier<Route> inner) 
- 
toStrictEntitypublic Route toStrictEntity(scala.concurrent.duration.FiniteDuration timeout, Supplier<Route> inner) Deprecated.As of 1.3.0, use the overloaded method taking ajava.time.Durationinstead.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 pekko.http.parsing.max-to-strict-bytesconfiguration setting.Extracts the pekko.http.javadsl.server.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)
 
- 
toStrictEntityWARNING: 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 pekko.http.parsing.max-to-strict-bytesconfiguration setting.Extracts the pekko.http.javadsl.server.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)
- Since:
- 1.3.0
 
- 
toStrictEntitypublic Route toStrictEntity(scala.concurrent.duration.FiniteDuration timeout, long maxBytes, Supplier<Route> inner) Deprecated.As of 1.3.0, use the overloaded method taking ajava.time.Durationinstead.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 pekko.http.parsing.max-to-strict-bytesconfiguration setting.Extracts the pekko.http.javadsl.server.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)
 
- 
toStrictEntityWARNING: 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 pekko.http.parsing.max-to-strict-bytesconfiguration setting.Extracts the pekko.http.javadsl.server.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)
- Since:
- 1.3.0
 
- 
withExecutionContextpublic Route withExecutionContext(scala.concurrent.ExecutionContextExecutor ec, Supplier<Route> inner) Runs its inner route with the given alternativeExecutionContextExecutor.- Parameters:
- ec- (undocumented)
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
withLogRuns its inner route with the given alternativeLoggingAdapter.- Parameters:
- log- (undocumented)
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
withMaterializerRuns its inner route with the given alternativepekko.stream.Materializer.- Parameters:
- mat- (undocumented)
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
withSettingsRuns its inner route with the given alternativeRoutingSettings.- Parameters:
- s- (undocumented)
- inner- (undocumented)
- Returns:
- (undocumented)
 
 
- 
java.time.Durationinstead.