aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlad Uspensky <v.uspenskiy@icloud.com>2017-05-25 17:23:30 -0700
committerGitHub <noreply@github.com>2017-05-25 17:23:30 -0700
commit20eac98ae18475f2d6dcaede653f6e9600673fc6 (patch)
tree07a1d135a4b6225a960d78f00a0e2e9084261984
parentd1bc91b0b52939c46a02233390d304870c90c2bf (diff)
parent9cff219fa07f516517e13300c14c63ac71043476 (diff)
downloaddriver-core-20eac98ae18475f2d6dcaede653f6e9600673fc6.tar.gz
driver-core-20eac98ae18475f2d6dcaede653f6e9600673fc6.tar.bz2
driver-core-20eac98ae18475f2d6dcaede653f6e9600673fc6.zip
Merge pull request #42 from drivergroup/allow-originv0.13.1
Allow websites to work directly with Scala APIs
-rw-r--r--src/main/scala/xyz/driver/core/app.scala7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main/scala/xyz/driver/core/app.scala b/src/main/scala/xyz/driver/core/app.scala
index b9209af..eb9f7ee 100644
--- a/src/main/scala/xyz/driver/core/app.scala
+++ b/src/main/scala/xyz/driver/core/app.scala
@@ -7,7 +7,7 @@ import akka.http.scaladsl.Http
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.model._
-import akka.http.scaladsl.model.headers.RawHeader
+import akka.http.scaladsl.model.headers.{HttpOriginRange, RawHeader, `Access-Control-Allow-Origin`}
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.RouteResult._
import akka.http.scaladsl.server.{ExceptionHandler, Route, RouteConcatenation}
@@ -102,7 +102,10 @@ object app {
handleExceptions(ExceptionHandler(exceptionHandler))({ c =>
requestLogging.flatMap { _ =>
- respondWithHeaders(List(RawHeader(ContextHeaders.TrackingIdHeader, trackingId))) {
+ val responseHeaders = List[HttpHeader](RawHeader(ContextHeaders.TrackingIdHeader, trackingId),
+ `Access-Control-Allow-Origin`(HttpOriginRange.*))
+
+ respondWithHeaders(responseHeaders) {
modules.map(_.route).foldLeft(versionRt ~ healthRoute ~ swaggerRoutes)(_ ~ _)
}(c)
}