Last active
August 29, 2015 13:56
Revisions
-
caniszczyk revised this gist
Feb 12, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ val apiService = Service.mk[AuthReq, Res] { req => Future.collect(tweets) map tweetsToJson(_) } } } //#3 Http.serve(":80", authFilter andThen apiService) // #4 // #1 Create a client for each service // #2 Create new Filter to authenticate incoming requests -
caniszczyk created this gist
Feb 10, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ val timelineSvc = Thrift.newIface[TimelineService](...) // #1 val tweetSvc = Thrift.newIface[TweetService](...) val authSvc = Thrift.newIface[AuthService](...) val authFilter = Filter.mk[Req, AuthReq, Res, Res] { (req, svc) => // #2 authSvc.authenticate(req) flatMap svc(_) } val apiService = Service.mk[AuthReq, Res] { req => timelineSvc(req.userId) flatMap {tl => val tweets = tl map tweetSvc.getById(_) Future.collect(tweets) map tweetsToJson(_) } } } //#3 Http.serve(“:80“, authFilter andThen apiService) // #4 // #1 Create a client for each service // #2 Create new Filter to authenticate incoming requests // #3 Create a service to convert an authenticated timeline request to a json response // #4 Start a new HTTP server on port 80 using the authenticating filter and our service