aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/core/app/DriverApp.scala
diff options
context:
space:
mode:
authorzachdriver <zach@driver.xyz>2018-05-09 14:50:03 -0700
committerGitHub <noreply@github.com>2018-05-09 14:50:03 -0700
commitb844c843f3b4433b37ddd2d7e8c10a183c47ca08 (patch)
tree893a7860724a0b368dbc3f7bff9072b4e1dc600b /src/main/scala/xyz/driver/core/app/DriverApp.scala
parent6fde5b828ee0f131536d0df0caf68e712742de53 (diff)
downloaddriver-core-b844c843f3b4433b37ddd2d7e8c10a183c47ca08.tar.gz
driver-core-b844c843f3b4433b37ddd2d7e8c10a183c47ca08.tar.bz2
driver-core-b844c843f3b4433b37ddd2d7e8c10a183c47ca08.zip
API-1595 Move rejectionHandler to DriverApp to avoid 404 rejection issues (#167)v1.9.1
Diffstat (limited to 'src/main/scala/xyz/driver/core/app/DriverApp.scala')
-rw-r--r--src/main/scala/xyz/driver/core/app/DriverApp.scala11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/scala/xyz/driver/core/app/DriverApp.scala b/src/main/scala/xyz/driver/core/app/DriverApp.scala
index bf18c3d..56ee898 100644
--- a/src/main/scala/xyz/driver/core/app/DriverApp.scala
+++ b/src/main/scala/xyz/driver/core/app/DriverApp.scala
@@ -127,7 +127,7 @@ class DriverApp(
val combinedRoute =
Route.seal(modules.map(_.route).foldLeft(basicRoutes.routeWithDefaults)(_ ~ _) ~ defaultOptionsRoute)
- (extractHost & extractClientIP & trace(tracer)) {
+ (extractHost & extractClientIP & trace(tracer) & handleRejections(authenticationRejectionHandler)) {
case (origin, ip) =>
ctx =>
val trackingId = extractTrackingId(ctx.request)
@@ -153,6 +153,15 @@ class DriverApp(
}
}
+ protected def authenticationRejectionHandler: RejectionHandler =
+ RejectionHandler
+ .newBuilder()
+ .handle {
+ case AuthenticationFailedRejection(_, challenge) =>
+ complete(HttpResponse(StatusCodes.Unauthorized, entity = challenge.realm))
+ }
+ .result()
+
protected def bindHttp(modules: Seq[Module]): Unit = {
val _ = http.bindAndHandle(route2HandlerFlow(appRoute), interface, port)(materializer)
}