Package akka.http.scaladsl.server
Interface RequestContext
- All Known Implementing Classes:
RequestContextImpl
public interface RequestContext
This class is not meant to be extended by user code.
Immutable object encapsulating the context of an HttpRequest
as it flows through a akka-http Route structure.
-
Method Summary
Modifier and TypeMethodDescriptionscala.concurrent.Future<RouteResult>
Completes the request with the given ToResponseMarshallable.scala.concurrent.ExecutionContextExecutor
The default ExecutionContext to be used for scheduling asynchronous logic related to this request.scala.concurrent.Future<RouteResult>
Bubbles the given error up the response chain where it is dealt with by the closesthandleExceptions
directive and itsExceptionHandler
, unless the error is aRejectionError
.akka.event.LoggingAdapter
log()
The default LoggingAdapter to be used for logging messages related to this request.mapRequest
(scala.Function1<HttpRequest, HttpRequest> f) Returns a copy of this context with the HttpRequest transformed by the given function.mapUnmatchedPath
(scala.Function1<Uri.Path, Uri.Path> f) Returns a copy of this context with the unmatchedPath transformed by the given function.akka.stream.Materializer
The default Materializer.The default ParserSettings to be used for configuring directives.reconfigure
(scala.concurrent.ExecutionContextExecutor executionContext, akka.stream.Materializer materializer, akka.event.LoggingAdapter log, RoutingSettings settings) Returns a copy of this context with the given fields updated.scala.concurrent.Future<RouteResult>
redirect
(Uri uri, StatusCodes.Redirection redirectionType) Completes the request with redirection response of the given type to the given URI.scala.concurrent.Future<RouteResult>
Rejects the request with the given rejections.request()
The request this context represents.settings()
The default RoutingSettings to be used for configuring directives.The unmatched path of this context.Removes a potentially existing Accept header from the request headers.withExecutionContext
(scala.concurrent.ExecutionContextExecutor ec) Returns a copy of this context with the new HttpRequest.withLog
(akka.event.LoggingAdapter log) Returns a copy of this context with the new LoggingAdapter.withMaterializer
(akka.stream.Materializer materializer) Returns a copy of this context with the new HttpRequest.withParserSettings
(ParserSettings settings) Returns a copy of this context with the newParserSettings
.withRequest
(HttpRequest req) Returns a copy of this context with the new HttpRequest.withRoutingSettings
(RoutingSettings settings) Returns a copy of this context with the new RoutingSettings.withUnmatchedPath
(Uri.Path path) Returns a copy of this context with the unmatched path updated to the given one.
-
Method Details
-
complete
Completes the request with the given ToResponseMarshallable.- Parameters:
obj
- (undocumented)- Returns:
- (undocumented)
-
executionContext
scala.concurrent.ExecutionContextExecutor executionContext()The default ExecutionContext to be used for scheduling asynchronous logic related to this request.- Returns:
- (undocumented)
-
fail
Bubbles the given error up the response chain where it is dealt with by the closesthandleExceptions
directive and itsExceptionHandler
, unless the error is aRejectionError
. In this case the wrapped rejection is unpacked and "executed".- Parameters:
error
- (undocumented)- Returns:
- (undocumented)
-
log
akka.event.LoggingAdapter log()The default LoggingAdapter to be used for logging messages related to this request.- Returns:
- (undocumented)
-
mapRequest
Returns a copy of this context with the HttpRequest transformed by the given function.- Parameters:
f
- (undocumented)- Returns:
- (undocumented)
-
mapUnmatchedPath
Returns a copy of this context with the unmatchedPath transformed by the given function.- Parameters:
f
- (undocumented)- Returns:
- (undocumented)
-
materializer
akka.stream.Materializer materializer()The default Materializer.- Returns:
- (undocumented)
-
parserSettings
ParserSettings parserSettings()The default ParserSettings to be used for configuring directives.- Returns:
- (undocumented)
-
reconfigure
RequestContext reconfigure(scala.concurrent.ExecutionContextExecutor executionContext, akka.stream.Materializer materializer, akka.event.LoggingAdapter log, RoutingSettings settings) Returns a copy of this context with the given fields updated.- Parameters:
executionContext
- (undocumented)materializer
- (undocumented)log
- (undocumented)settings
- (undocumented)- Returns:
- (undocumented)
-
redirect
Completes the request with redirection response of the given type to the given URI.- Parameters:
uri
- (undocumented)redirectionType
- (undocumented)- Returns:
- (undocumented)
-
reject
Rejects the request with the given rejections.- Parameters:
rejections
- (undocumented)- Returns:
- (undocumented)
-
request
HttpRequest request()The request this context represents. Modelled as a `val` so as to enable an `import ctx.request._`. -
settings
RoutingSettings settings()The default RoutingSettings to be used for configuring directives.- Returns:
- (undocumented)
-
unmatchedPath
Uri.Path unmatchedPath()The unmatched path of this context. Modelled as a `val` so as to enable an `import ctx.unmatchedPath._`. -
withAcceptAll
RequestContext withAcceptAll()Removes a potentially existing Accept header from the request headers.- Returns:
- (undocumented)
-
withExecutionContext
Returns a copy of this context with the new HttpRequest.- Parameters:
ec
- (undocumented)- Returns:
- (undocumented)
-
withLog
Returns a copy of this context with the new LoggingAdapter.- Parameters:
log
- (undocumented)- Returns:
- (undocumented)
-
withMaterializer
Returns a copy of this context with the new HttpRequest.- Parameters:
materializer
- (undocumented)- Returns:
- (undocumented)
-
withParserSettings
Returns a copy of this context with the newParserSettings
.- Parameters:
settings
- (undocumented)- Returns:
- (undocumented)
-
withRequest
Returns a copy of this context with the new HttpRequest.- Parameters:
req
- (undocumented)- Returns:
- (undocumented)
-
withRoutingSettings
Returns a copy of this context with the new RoutingSettings.- Parameters:
settings
- (undocumented)- Returns:
- (undocumented)
-
withUnmatchedPath
Returns a copy of this context with the unmatched path updated to the given one.- Parameters:
path
- (undocumented)- Returns:
- (undocumented)
-