Last active
October 20, 2015 16:48
-
-
Save trane/53818c947c3777cf68fd to your computer and use it in GitHub Desktop.
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
| // this is with POC (plain old curry) | |
| // () => Filter | |
| val loginPostService = new ExceptionFilter andThen | |
| new ServiceFilter(serviceMatcher) andThen | |
| new SessionIdFilter(sessionStore) andThen | |
| new KeymasterLoginFilter(sessionStore) andThen | |
| new KeymasterIdentityProvider(keymasterClient, Path(keymasterIdentityProviderPath)) | |
| // (ServerConfig) => Filter | |
| val loginPostService: ServerConfig => Filter = config => { | |
| new ExceptionFilter andThen | |
| new ServiceFilter(config.serviceMatcher) andThen | |
| new SessionIdFilter(config.sessionStore) andThen | |
| new KeymasterLoginFilter(config.sessionStore) andThen | |
| new KeymasterIdentityProvider(config.keymasterClient, Path(keymasterIdentityProviderPath)) | |
| } | |
| val routingService1: ServerConfig => RoutingService = config => { | |
| RoutingService.byMethodAndPathObject { | |
| case Method.Post -> Root / "login" => loginPostService(config) | |
| case Method.Get -> Root / "login" => loginGetService(config) | |
| case _ => allOtherRequests(config) | |
| } | |
| } | |
| Httpx.serve(...., routingService1(config)) | |
| // when we have a smart compiler (no java, your compiler sucks) | |
| // we can have the compiler do the work for us | |
| // () => Filter | |
| val loginPostService = new ExceptionFilter andThen | |
| new ServiceFilter(serviceMatcher) andThen | |
| new SessionIdFilter(sessionStore) andThen | |
| new KeymasterLoginFilter(sessionStore) andThen | |
| new KeymasterIdentityProvider(keymasterClient, Path(keymasterIdentityProviderPath)) | |
| // (implicit ServerConfig) => Filter | |
| def loginPostService(implicit config: ServerConfig): Filter = | |
| new ExceptionFilter andThen | |
| new ServiceFilter(config.serviceMatcher) andThen | |
| new SessionIdFilter(config.sessionStore) andThen | |
| new KeymasterLoginFilter(config.sessionStore) andThen | |
| new KeymasterIdentityProvider(config.keymasterClient, Path(keymasterIdentityProviderPath)) | |
| val routingService1(implicit config: ServerConfig): RoutingService = | |
| RoutingService.byMethodAndPathObject { | |
| case Method.Post -> Root / "login" => loginPostService(config) | |
| case Method.Get -> Root / "login" => loginGetService(config) | |
| case _ => allOtherRequests(config) | |
| } | |
| implicit val config = ServerConfig(???, ???, ???, ???) | |
| Httpx.serve(...., routingService1) | |
| object ServerInstances { | |
| implicits ... | |
| } | |
| object BpApp extends TwitterServer { | |
| import ServerInstances._ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment