This file contains 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
package me.sgrouples.rogue | |
import io.fsq.field.Field | |
import shapeless._ | |
import labelled.{FieldType, field} | |
import syntax.singleton._ | |
import record._ | |
import ops.record._ | |
import org.bson.{BsonDocument, BsonNull, BsonValue} | |
import shapeless.syntax.SingletonOps |
This file contains 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
trait HttpClient { | |
implicit def system: ActorSystem | |
implicit def materializer: ActorMaterializer | |
def connectionContext: HttpsConnectionContext | |
protected val http = Http() | |
//execs only if result was successful |
This file contains 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] | |
} |