Created
March 29, 2016 18:28
-
-
Save marekzebrowski/c3c4d24b4ffbcb219036eb175233728a to your computer and use it in GitHub Desktop.
akka-http-auth-help
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def logUserIn(token:String):Future[Option[UserId]] = ??? | |
val withUserId: Directive1[User.Id] = { | |
extractExecutionContext.flatMap { implicit ec => | |
headerValueByType[Authorization]().flatMap { authHdr => | |
{ | |
onSuccess(logUserIn(authHdr)).flatMap { | |
case Some(userId) => provide[UserId](userId): Directive1[UserId] | |
case None => reject(MissingHeaderRejection(Authorization.name)): Directive1[UserId] | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[info] Compiling 1 Scala source to /Users/mar/git/sgrouples/target/scala-2.11/classes...
[warn] /Users/mar/git/sgrouples/src/main/scala/me/sgrouples/lib/rest/akkahttp/ChatApi.scala:91: Adaptation of argument list by inserting () has been deprecated: this is unlikely to be what you want.
[warn] signature: HeaderDirectives.headerValueByType[T <: akka.http.scaladsl.model.HttpHeader](magnet: akka.http.scaladsl.server.util.ClassMagnet[T]): akka.http.scaladsl.server.Directive1[T]
[warn] given arguments:
[warn] after adaptation: HeaderDirectives.headerValueByType((): Unit)
[warn] headerValueByTypeAuthorization.flatMap { authHdr =>
[warn] ^
[warn] one warning found