!htc #19514,#18958 make config in HTTP non-case class + from reference
This commit is contained in:
parent
97df7bf689
commit
9b4b68f0c9
17 changed files with 215 additions and 124 deletions
|
|
@ -5,7 +5,9 @@
|
|||
package akka.http.scaladsl.server
|
||||
|
||||
import akka.NotUsed
|
||||
import akka.stream.Materializer
|
||||
import akka.actor.ActorSystem
|
||||
import akka.http.ParserSettings
|
||||
import akka.stream.{ ActorMaterializer, Materializer }
|
||||
|
||||
import scala.concurrent.{ ExecutionContextExecutor, Future }
|
||||
import akka.stream.scaladsl.Flow
|
||||
|
|
@ -23,6 +25,7 @@ object Route {
|
|||
* "Seals" a route by wrapping it with exception handling and rejection conversion.
|
||||
*/
|
||||
def seal(route: Route)(implicit routingSettings: RoutingSettings,
|
||||
parserSettings: ParserSettings = null,
|
||||
rejectionHandler: RejectionHandler = RejectionHandler.default,
|
||||
exceptionHandler: ExceptionHandler = null): Route = {
|
||||
import directives.ExecutionDirectives._
|
||||
|
|
@ -39,6 +42,7 @@ object Route {
|
|||
* This conversion is also implicitly available through [[RouteResult.route2HandlerFlow]].
|
||||
*/
|
||||
def handlerFlow(route: Route)(implicit routingSettings: RoutingSettings,
|
||||
parserSettings: ParserSettings,
|
||||
materializer: Materializer,
|
||||
routingLog: RoutingLog,
|
||||
executionContext: ExecutionContextExecutor = null,
|
||||
|
|
@ -50,6 +54,7 @@ object Route {
|
|||
* Turns a `Route` into an async handler function.
|
||||
*/
|
||||
def asyncHandler(route: Route)(implicit routingSettings: RoutingSettings,
|
||||
parserSettings: ParserSettings,
|
||||
materializer: Materializer,
|
||||
routingLog: RoutingLog,
|
||||
executionContext: ExecutionContextExecutor = null,
|
||||
|
|
@ -59,10 +64,11 @@ object Route {
|
|||
|
||||
{
|
||||
implicit val executionContext = effectiveEC // overrides parameter
|
||||
val effectiveParserSettings = if (parserSettings ne null) parserSettings else ParserSettings(ActorMaterializer.downcast(materializer).system)
|
||||
|
||||
val sealedRoute = seal(route)
|
||||
request ⇒
|
||||
sealedRoute(new RequestContextImpl(request, routingLog.requestLog(request), routingSettings)).fast
|
||||
sealedRoute(new RequestContextImpl(request, routingLog.requestLog(request), routingSettings, effectiveParserSettings)).fast
|
||||
.map {
|
||||
case RouteResult.Complete(response) ⇒ response
|
||||
case RouteResult.Rejected(rejected) ⇒ throw new IllegalStateException(s"Unhandled rejections '$rejected', unsealed RejectionHandler?!")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue