Last active
May 10, 2016 01:10
-
-
Save DeaconDesperado/12684e14de3769b4e3d6e6336c61276d to your computer and use it in GitHub Desktop.
Too much cake!
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 Registry { | |
val ec:ExecutionContext | |
val userService = new UserServiceImpl(ec) | |
val fooBarService = new FoobarServiceImpl(userService) | |
} | |
class RestActor extends Registry with UserRoutes { | |
def receive = { | |
userRoutes ~ | |
otherRoutesFromOtherMixins | |
} | |
} | |
trait AccessDirectives extends Directives { | |
self: Registry => | |
val letMeIn:Directive1[Option[User]] = optionalHeaderValueByName("user_auth").hflatMap { | |
case Some(id) :: HNil => onSuccess(userService.get(id)) | |
case _ => reject() | |
} | |
} | |
trait UserRoutes extends AccessDirectives with HttpService { | |
self: Registry => | |
val userRoutes = { | |
path(Segment){ userId => | |
onSuccess(userService.get(userId)){ user => | |
complete(user) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment